SBoudrias/Inquirer.js

Don't reject with standard error on exit signal

mondeja opened this issue · 3 comments

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?

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!

Latest versions include the changes! Thanks again

Great. Thank you!