refactor(errors): unify EkbError hierarchy across domains and structured CLI error classification
This commit is contained in:
1 parent
2b220bc5d9
commit
c15d622ba2
8 files changed
+89
-40
No files matched your search
@@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user