export class EkbError extends Error { constructor( message: string, public readonly code: string, public readonly status?: number ) { super(message); this.name = "EkbError"; } } 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"; } } export class BusinessError extends EkbError { constructor(message: string, code = "BUSINESS_ERROR", status = 400) { super(message, code, status); this.name = "BusinessError"; } } export class EkbApiError extends EkbError { constructor(message: string, code = "API_ERROR", status = 500) { super(message, code, status); this.name = "EkbApiError"; } }