This commit is contained in:
2025-05-23 19:03:44 +00:00
parent 7d28d23bbd
commit 1b141ec8f3
101 changed files with 30736 additions and 374 deletions

View File

@ -16,10 +16,17 @@ export * from './email.errors.js';
export * from './mta.errors.js';
export * from './reputation.errors.js';
// Export error handler
export * from './error-handler.js';
// Export utility function to create specific error types based on the error category
import { getErrorClassForCategory } from './base.errors.js';
export { getErrorClassForCategory };
// Import needed classes for utility functions
import { PlatformError } from './base.errors.js';
import { ErrorSeverity, ErrorCategory, ErrorRecoverability } from './error.codes.js';
/**
* Create a typed error from a standard Error
* Useful for converting errors from external libraries or APIs
@ -33,11 +40,7 @@ export function fromError(
error: Error,
code: string,
contextData: Record<string, any> = {}
) {
// Import and use PlatformError
const { PlatformError } = require('./base.errors.js');
const { ErrorSeverity, ErrorCategory, ErrorRecoverability } = require('./error.codes.js');
): PlatformError {
return new PlatformError(
error.message,
code,
@ -66,7 +69,6 @@ export function fromError(
export function isRetryable(error: any): boolean {
// If it's our platform error, use its recoverability property
if (error && typeof error === 'object' && 'recoverability' in error) {
const { ErrorRecoverability } = require('./error.codes.js');
return error.recoverability === ErrorRecoverability.RECOVERABLE ||
error.recoverability === ErrorRecoverability.MAYBE_RECOVERABLE ||
error.recoverability === ErrorRecoverability.TRANSIENT;