feat: CLI 错误类层次

This commit is contained in:
2026-06-08 22:30:03 +08:00
parent bafbbaa01e
commit dab63975f5
2 changed files with 81 additions and 0 deletions

26
src/cli/errors.ts Normal file
View File

@@ -0,0 +1,26 @@
export class CliError extends Error {
readonly hint?: string;
readonly usage?: string;
constructor(
message: string,
opts?: { hint?: string; usage?: string },
) {
super(message);
this.name = this.constructor.name;
this.hint = opts?.hint;
this.usage = opts?.usage;
}
}
export class UsageError extends CliError {}
export class ConfigError extends CliError {}
export class CommandError extends CliError {}
export class InternalError extends CliError {
constructor() {
super("发生了未预期的错误");
}
}