Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't show unhandled error twice #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ export async function runMain<T extends ArgsDef = ArgsDef>(
}
} catch (error: any) {
const isCLIError = error instanceof CLIError;
if (!isCLIError) {
consola.error(error, "\n");
}
if (isCLIError) {
await showUsage(...(await resolveSubCommand(cmd, rawArgs)));
} else {
consola.error(error, "\n");
}
consola.error(error.message);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only two conditions, is cli error or not, so we can make sure there must be something printed already, if the erroris undefined theerror.message` should be empty or raise a runtime error. So just remove it to avoid printing duplicated error.

process.exit(1);
}
}
Expand Down