[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

feat: handle missed errors

Bruno Rocha (Apr 13, 2023, 12:11 PM -0300) 4546906e 160027b9

+9 -14
+9 -14
packages/prompts/src/index.ts
··· 642 642 unblock(); 643 643 }; 644 644 645 - const handleExit = (code: number) => { 646 - if (isSpinnerActive) { 647 - stop(code > 1 ? 'Something went wrong' : 'Canceled', code); 648 - } 645 + const handleExit = (code: number, error?: unknown) => { 646 + const message = code > 1 ? 'Something went wrong' : 'Canceled'; 647 + if (isSpinnerActive) stop(message, code); 648 + if (error) console.error(error); 649 649 }; 650 650 651 - /** 652 - * Signal Events: https://nodejs.org/api/process.html#signal-events 653 - * `uncaughtException`: Trigger on uncaught code exception 654 - * `unhandledRejection`: Trigger on unhandled promise rejection 655 - * `SIGINT`: Trigger on Ctrl + C. PS: it will not trigger while terminal raw mode is enabled 656 - * `SIGTERM`: Trigger on kill process 657 - * `exit`: Trigger on exit 658 - */ 659 - process.on('uncaughtException', () => handleExit(2)); 660 - process.on('unhandledRejection', () => handleExit(2)); 651 + // Reference: https://nodejs.org/api/process.html#event-uncaughtexception 652 + process.on('uncaughtException', (error) => handleExit(2, error)); 653 + // Reference: https://nodejs.org/api/process.html#event-unhandledrejection 654 + process.on('unhandledRejection', (error) => handleExit(2, error)); 655 + // Reference Signal Events: https://nodejs.org/api/process.html#signal-events 661 656 process.on('SIGINT', () => handleExit(1)); 662 657 process.on('SIGTERM', () => handleExit(1)); 663 658 process.on('exit', handleExit);