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
Safely exit by throwing an error #546
Conversation
Is there a way to make the message be part of the new stack trace? That would be even better. |
Do you mean the |
Yeah, that's what I meant |
@freitagbr is it standard to prepend to the message like that? |
Probably not, so I will suggest a different option: changing the error name to |
@freitagbr that could work |
I toyed around with the idea of creating an internal error class, but in this instance, I think just changing the name should suffice. |
LGTM. Moving this to the dev branch since it's a breaking change. Hopefully we don't have to worry about unexpected scenarios where you can't assign to properties of exception is caught. This approach should be perfectly fine for any real exception. |
@freitagbr it looks like we may have lost this commit on dev branch with a force push (I wish github supported auto merging). I'll just stick with manual merges instead of rebases to update dev branch. Would you be able to redo this commit? |
Yeah, let me do redo this. |
Fixes #483.
Instead of exiting the process with
process.exit(1)
, simply throw an error. This way, the error can be caught by Node itself. If the error is not caught, the error is still printed, and the process exits with a1
.