Assist_Design/packages/domain/common/provider-errors.ts

81 lines
2.1 KiB
TypeScript
Raw Normal View History

/**
* 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",
// Validation
VALIDATION_ERROR: "SF_VALIDATION_ERROR",
DUPLICATE_RECORD: "SF_DUPLICATE_RECORD",
ACCESS_DENIED: "SF_ACCESS_DENIED",
STORAGE_LIMIT: "SF_STORAGE_LIMIT",
// 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 = {
// Not found
ACCOUNT_NOT_FOUND: "FREEBIT_ACCOUNT_NOT_FOUND",
// Authentication
AUTH_FAILED: "FREEBIT_AUTH_FAILED",
// Validation
VALIDATION_ERROR: "FREEBIT_VALIDATION_ERROR",
// Network/Infrastructure
TIMEOUT: "FREEBIT_TIMEOUT",
NETWORK_ERROR: "FREEBIT_NETWORK_ERROR",
RATE_LIMITED: "FREEBIT_RATE_LIMITED",
// Generic
API_ERROR: "FREEBIT_API_ERROR",
} as const;
export type FreebitProviderErrorCode =
(typeof FreebitProviderError)[keyof typeof FreebitProviderError];