feat: CLI 错误类层次
This commit is contained in:
26
src/cli/errors.ts
Normal file
26
src/cli/errors.ts
Normal 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("发生了未预期的错误");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user