| 21 | |
| 22 | /** @type {(err: any) => void} */ |
| 23 | const errorHandler = err => { |
| 24 | if (currentCommand) { |
| 25 | try { |
| 26 | currentCommand.dispose(); |
| 27 | } catch {} |
| 28 | } |
| 29 | logger.error(err); |
| 30 | process.exit(1); |
| 31 | }; |
| 32 | process.on('unhandledRejection', errorHandler); |
| 33 | process.on('uncaughtException', errorHandler); |
| 34 |