Skip to content
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

Don't reject with standard error on exit signal #1368

Closed
mondeja opened this issue Mar 8, 2024 · 3 comments · Fixed by #1369
Closed

Don't reject with standard error on exit signal #1368

mondeja opened this issue Mar 8, 2024 · 3 comments · Fixed by #1369

Comments

@mondeja
Copy link

mondeja commented Mar 8, 2024

I'm trying to handle a SIGINT signal (tipically pressing Ctrl^C) on a script but this raises a standard error:

reject(new Error(`User force closed the prompt with ${code} ${signal}`));

I would like to catch a custom error instead. I know that I can use something like checking the error message, but that sounds like crazy to me, because it could lead to catch other errors or break if another released version changes this message.

Please, could you throw a custom error that I could be able to properly catch to exit when SIGINT is received?

@mondeja mondeja changed the title Don't reject with standard error on signal exit Don't reject with standard error on exit signal Mar 9, 2024
@SBoudrias
Copy link
Owner

Hey, that's a good call out! Thanks for raising the issue.

I've made a first draft PR to address that issue. It'd be great if you could review the code and make sure that would work for you!

@SBoudrias
Copy link
Owner

Latest versions include the changes! Thanks again

@mondeja
Copy link
Author

mondeja commented Mar 13, 2024

Great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants