News for hackers. Stuff that matters.
Re:Error Handling in Node.js by prodigal_erik on Friday November 04, 2016 @05:40AM (#12871314)
Error.prototype.toString() reads e.name, not e.prototype.constructor.name, so you can't rely on everyone to have subclassed Error.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:Error Handling in Node.js by Illniyar on Friday November 04, 2016 @07:52AM (#12871842)
I'm not following, why can't I use:

   e instanceof Error
or:

   e instanceof MyError
why does toString() have anything to do with this?
Re:Error Handling in Node.js by prodigal_erik on Friday November 04, 2016 @12:51PM (#12873980)
It's very likely someone did

  const e = new Error('bad stuff happened')
  e.name = 'MyError'
without actually creating a MyError class to check with instanceof.
Re:Error Handling in Node.js by Illniyar on Friday November 04, 2016 @03:09PM (#12875082)
Unless it's common in popular libraries/packages, I don't see why I need to take it into account.

Which popular libraries do this?

If it's just in a few places, it should be handled specifically, and use sane choices in other places.

Re:Error Handling in Node.js by pags on Friday November 04, 2016 @09:56AM (#12872563)
This is what I do when working with my own Error types.