-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for (or document) Error#cause #50
Comments
There is library make-error-cause which allows to create Errors with causes. It is fairly popular (600k downloads per week). The I currently use custom
Kudos for Still it would be nice if If that is something you're interested in, I can make a PR. |
I went ahead and tried to implement this, but the line
is in the way of serializing the Maybe |
To add more context, here's the current support:
This is the result of: // Extra wrappers to test the stack visibility as well
function throwing () {
throw new TypeError('original error')
}
function catcher() {
try {
throwing()
} catch (typeError) {
const extendedError = new Error('Wrapped error with more info')
extendedError.cause = typeError;
throw extendedError;
}
}
async function init() {
catcher()
}
init().catch(error => {
console.log({
error,
serialized: serializeError(error),
seriaDeseria: deserializeError(serializeError(error))
})
}) |
Correction:
My example worked because I set the |
Context:
I think this already kind of supported, but it should probably be documented and tested, especially if #48 is implemented
The text was updated successfully, but these errors were encountered: