Add structured error code enums to domain package for WHMCS, Salesforce, and Freebit providers. Create BaseProviderError and typed error classes for each provider. Update UnifiedExceptionFilter to handle provider errors. Migrate all three error handler services from DomainHttpException with brittle string matching to typed error classes with instanceof checks.
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
/**
|
|
* Provider-specific error codes for structured error detection.
|
|
*
|
|
* These codes identify known error conditions from external providers.
|
|
* Used by provider error classes in the BFF to replace brittle string matching.
|
|
*/
|
|
|
|
export const WhmcsProviderError = {
|
|
// Authentication
|
|
AUTH_FAILED: "WHMCS_AUTH_FAILED",
|
|
INVALID_CREDENTIALS: "WHMCS_INVALID_CREDENTIALS",
|
|
|
|
// Not found
|
|
CLIENT_NOT_FOUND: "WHMCS_CLIENT_NOT_FOUND",
|
|
INVOICE_NOT_FOUND: "WHMCS_INVOICE_NOT_FOUND",
|
|
PRODUCT_NOT_FOUND: "WHMCS_PRODUCT_NOT_FOUND",
|
|
|
|
// Validation
|
|
VALIDATION_ERROR: "WHMCS_VALIDATION_ERROR",
|
|
|
|
// Network/Infrastructure
|
|
TIMEOUT: "WHMCS_TIMEOUT",
|
|
NETWORK_ERROR: "WHMCS_NETWORK_ERROR",
|
|
RATE_LIMITED: "WHMCS_RATE_LIMITED",
|
|
HTTP_ERROR: "WHMCS_HTTP_ERROR",
|
|
|
|
// Generic
|
|
API_ERROR: "WHMCS_API_ERROR",
|
|
} as const;
|
|
|
|
export type WhmcsProviderErrorCode = (typeof WhmcsProviderError)[keyof typeof WhmcsProviderError];
|
|
|
|
export const SalesforceProviderError = {
|
|
// Authentication
|
|
SESSION_EXPIRED: "SF_SESSION_EXPIRED",
|
|
AUTH_FAILED: "SF_AUTH_FAILED",
|
|
|
|
// Query
|
|
QUERY_ERROR: "SF_QUERY_ERROR",
|
|
RECORD_NOT_FOUND: "SF_RECORD_NOT_FOUND",
|
|
|
|
// Network/Infrastructure
|
|
TIMEOUT: "SF_TIMEOUT",
|
|
NETWORK_ERROR: "SF_NETWORK_ERROR",
|
|
RATE_LIMITED: "SF_RATE_LIMITED",
|
|
|
|
// Generic
|
|
API_ERROR: "SF_API_ERROR",
|
|
} as const;
|
|
|
|
export type SalesforceProviderErrorCode =
|
|
(typeof SalesforceProviderError)[keyof typeof SalesforceProviderError];
|
|
|
|
export const FreebitProviderError = {
|
|
ACCOUNT_NOT_FOUND: "FREEBIT_ACCOUNT_NOT_FOUND",
|
|
TIMEOUT: "FREEBIT_TIMEOUT",
|
|
API_ERROR: "FREEBIT_API_ERROR",
|
|
} as const;
|
|
|
|
export type FreebitProviderErrorCode =
|
|
(typeof FreebitProviderError)[keyof typeof FreebitProviderError];
|