Open seansfkelley opened 5 months ago
Here's a slapdash implementation I patched in with yarn patch
to my local installation so you can get a sense for what support might look like:
function recursivelyAppendCause(error, indent) {
if (error) {
if (error.stack) {
result += `${indent}[cause]: ${error.stack.split('\n').map(l => `${indent}${l}`).join('\n').replace(/^\s*/, '')}\n`;
} else {
result += `${indent}[cause]: [non-error object]\n${error}\n`;
}
recursivelyAppendCause(error.cause, indent + ' ');
}
}
recursivelyAppendCause(error.cause, ' ');
(in Cli#error
).
In ES2022 (I think?),
Error
s gained acause
attribute. The default behavior of Clipanion to format the error doesn't check for this field, onlystack
, so the causes of rethrown errors are silently dropped.I'd be happy to open a PR to add
cause
support to the default formatting behavior. I would have already but to make it typesafe I would have to change the tsconfig.json'slib
it compiles against (and potentially the TypeScript version itself?), and I don't know what compatibility requirements you have.cause
is supported since Node 16, which is now EOL.