I don't know if this applies everywhere, but it feels that if you're catching an error just to log it and then throwing it again, you're potentially passing the error to another step that will do the same, resulting in the same error being logged twice.
Alternatives:
log('there was an error', error); exit(1)
Error#cause
try {
null();
} catch (error) {
console.log('Error while doing stuff', error); // Log
throw error; // and re-throw
}
try {
null();
} catch (error) {
console.log(error); // Only log
}
try {
null();
} catch (error) {
doSomething(error);
throw error; // Re-throw
}
try {
null();
} catch (error) {
const specificError = new Error('Error while doing stuff')
specificError.cause = error
throw specificError; // Throw new error with more details
}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too