32 lines
662 B
TypeScript
32 lines
662 B
TypeScript
export class CliError extends Error {
|
|
summary: string;
|
|
code: string;
|
|
exitCode: number;
|
|
retryable: boolean;
|
|
data: unknown;
|
|
nextCommands: string[];
|
|
|
|
constructor(
|
|
summary: string,
|
|
code: string,
|
|
message: string,
|
|
exitCode = 2,
|
|
retryable = false,
|
|
data: unknown = null,
|
|
nextCommands: string[] = [],
|
|
) {
|
|
super(message);
|
|
this.summary = summary;
|
|
this.code = code;
|
|
this.exitCode = exitCode;
|
|
this.retryable = retryable;
|
|
this.data = data;
|
|
this.nextCommands = nextCommands;
|
|
}
|
|
}
|
|
|
|
export function errorMessage(error: unknown): string {
|
|
return error instanceof Error ? error.message : String(error);
|
|
}
|
|
|