feat(cli): improve error handling with more custom Error instances

This commit is contained in:
Joakim Carlstein 2023-11-16 12:01:32 +01:00
parent 8dadfe9a5b
commit 30a448b4cf
6 changed files with 123 additions and 21 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env node
import process from 'node:process';
import { parseArgs } from 'node:util';
import { ShowUsageError } from './show-usage-error.js';
import { ShowUsageError } from './errors.js';
import { getConfig } from './get-config.js';
type Action = (args: string[]) => Promise<void>;
@ -208,7 +208,7 @@ try {
if (error instanceof Error) {
console.error(error.message);
if (error.cause instanceof Error) {
console.error(error.cause.message);
console.error(error.cause.stack);
}
} else {
console.error(error);