Use a distinct type for an Error that was constructed with a cause
#189
davidhousedev
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Within our organization, we've encountered challenges when developers log an
Errorthat does not have acausedefined. When acauseis provided, it's much easier to trace back the reason why an exception occurred in production.Given that
causes have proven so useful to us, we're extending theErrorConstructorwith new overloads that will return a structurally-distinct type whencauseis provided,ErrorWithCause. This new type cannot be constructed directly (through the use of aprivateconstructor) which is a good thing because there is no JS implementation.Here's how we've extended our
reset.d.tsfiles locally in order to accomplish this:Would this be a useful addition to
ts-reset? Based on what I can tell, there might be some complexity around thetargetif the JS is being run in an environment that doesn't supportcauseonError.Beta Was this translation helpful? Give feedback.
All reactions