Open fabis94 opened 2 years ago
If it helps at all, the types appear to be compatible in newer TS versions https://github.com/microsoft/TypeScript/issues/50583 -- however I doubt any tooling will consider invoking the error.cause
fn so would be interesting to see if VError could improve compatibility.
Tbh, I tend to think VError
is becoming a little obsolete (due to it's own success!) because:
It might be worth creating a new version (or new package?) which:
info
property (perhaps with stricter typing)VError.info
, VError.findCauseByName
, VError.hasCauseWithName
, VError.errorFromList
and VError.errorForEach
I have done a bit of work on creating a more modern successor of verror here: https://github.com/jdpnielsen/contextual-error. I would very much like to collaborate on improving this - or starting a new project based on community needs.
My ponyfill for Error Causes includes helpers with backwards compatibility for VError causes, enabling one to iteratively move from VError to a more standardized solution: https://github.com/voxpelli/pony-cause
Especially when using
verror
with@types/verror
you'll quickly run into the issue of VError.prototype.cause (a function) conflicting with the new Error.prototype.cause (Error obj) API, that is already at stage 4 and thus not going anywhere - https://github.com/tc39/proposal-error-causeAre there any plans to make this library (and afterwards - its TS types) compatible with this new API? VError should ditch the
cause
function from the VError prototype, so that it doesn't conflict with the Error.prototype.cause type, and move this function to another name. This new function should also understand how to read both VError style 'cause' values and native Error style 'cause' values.