refactor(errors): unify EkbError hierarchy across domains and structured CLI error classification

This commit is contained in:
gitea committed 2026-09-30 00:13:35 +08:00
1 parent 2b220bc5d9
commit c15d622ba2
8 files changed
+89 -40

No files matched your search

+24
View File
@@ -12,12 +12,35 @@ export class EkbError extends Error {
export class NotLoggedInError extends EkbError {
constructor(message = "No corp selected") {
super(message, "NOT_LOGGED_IN", 401);
this.name = "NotLoggedInError";
}
}
export class AuthenticationError extends EkbError {
constructor(message = "Authentication failed") {
super(message, "AUTH_FAILED", 401);
this.name = "AuthenticationError";
}
}
export class PermissionError extends EkbError {
constructor(message = "Permission denied") {
super(message, "FORBIDDEN", 403);
this.name = "PermissionError";
}
}
export class NotFoundError extends EkbError {
constructor(message: string, code = "NOT_FOUND") {
super(message, code, 404);
this.name = "NotFoundError";
}
}
export class ValidationError extends EkbError {
constructor(message: string, code = "VALIDATION_ERROR") {
super(message, code, 400);
this.name = "ValidationError";
}
}
@@ -35,3 +58,4 @@ export class EkbApiError extends EkbError {
}
}