Open pimterry opened 7 years ago
Interesting idea from @emirotin: we could even have this throw in development environments using NODE_ENV
(if it's set and it's not production/staging).
This is not as easy as it sounds, for a few reasons:
.name
is used in the Error.toString()
, which is called when generating the stack trace in the Error
constructor, so a deprecation message would appear at every new MyTypedError()
call. You could override .toString
to fix this though..name
is used in Error.captureStackTrace
, which we need to use internally.name
is used in Bluebird's isError as part of its catch handling.I don't see any nice and easy way around those to let us catch incorrect usages of .name
. Instead, we're going to have to make it reliable. Thoughts on doing that nicely @emirotin @Page-? The best I can come up with is:
name
a required parameter when calling super()
..code
, for easy compatibility with our existing error checking code.Yeah, setting it explicitly is probably the way to go
As we saw in the UI incident yesterday,
.name
isn't reliable under minification. Can we avoid this? One nice deprecation route would be to replace it with a getter that works the same, but prints a deprecation warning any time you try to read it, which should let us quickly find anywhere else this might come up.