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
-
Within our organization, we've encountered challenges when developers log an
Error
that does not have acause
defined. When acause
is provided, it's much easier to trace back the reason why an exception occurred in production.Given that
cause
s have proven so useful to us, we're extending theErrorConstructor
with new overloads that will return a structurally-distinct type whencause
is provided,ErrorWithCause
. This new type cannot be constructed directly (through the use of aprivate
constructor) which is a good thing because there is no JS implementation.Here's how we've extended our
reset.d.ts
files 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 thetarget
if the JS is being run in an environment that doesn't supportcause
onError
.Beta Was this translation helpful? Give feedback.
All reactions