File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export class CLIError extends Error {
1616
1717/**
1818 * Wraps a CLI action / handler function with error handling that catches
19- * CLIError , prints it to the console, then exits. Other errors are rethrown .
19+ * errors , prints them to the console, then exits.
2020 * @param fn - Action handler
2121 * @returns Wrapped handler
2222 */
@@ -33,7 +33,13 @@ export function withErrorHandling<T extends unknown[]>(
3333 // eslint-disable-next-line unicorn/no-process-exit
3434 process . exit ( 1 ) ;
3535 }
36- throw error ;
36+ const message = error instanceof Error ? error . message : String ( error ) ;
37+ consola . error ( `Unexpected error: ${ message } ` ) ;
38+ if ( error instanceof Error && error . stack ) {
39+ consola . debug ( error . stack ) ;
40+ }
41+ // eslint-disable-next-line unicorn/no-process-exit
42+ process . exit ( 1 ) ;
3743 }
3844 } ;
3945}
You can’t perform that action at this time.
0 commit comments