/** * @module * Unified error hierarchy for sently transports and SMTP. */ /** Stable machine-readable error codes shared across providers. */ export type SentlyErrorCode = "INVALID_CONFIG" | "SMTP_AUTH_FAILED" | "RATE_LIMITED" | "TIMEOUT" | "CONNECTION_FAILED" | "PROVIDER_ERROR" | "BAD_REQUEST"; /** Options for constructing a {@link SentlyError}. */ export interface SentlyErrorOptions { /** HTTP status code when the failure originated from an HTTP transport. */ statusCode?: number; /** Original error or response payload. */ cause?: unknown; /** Provider identifier (e.g. `"smtp"`, `"resend"`). */ provider?: string; } /** * Base error class for all sently transport and protocol failures. * * Subclasses may shadow {@link code} with provider-specific or numeric values * (e.g. SMTP response codes). Use {@link sentlyCode} for the stable machine-readable * code in those cases. */ export declare class SentlyError extends Error { /** * Stable machine-readable error code. * Preserved even when a subclass shadows {@link code}. */ readonly sentlyCode: SentlyErrorCode; /** HTTP status code when applicable. */ readonly statusCode?: number; /** Provider identifier when applicable. */ readonly provider?: string; /** * Error code — machine-readable string on {@link SentlyError}, or a legacy * provider/SMTP-specific value on subclasses (numeric SMTP codes, Brevo/SES API codes). */ code: string | number; /** Creates a sently error with a machine-readable code and optional metadata. */ constructor(message: string, sentlyCode: SentlyErrorCode, options?: SentlyErrorOptions); } /** * Map an HTTP status code to a stable sently error code. * * @param status - HTTP response status code * @returns Machine-readable error code */ export declare function httpStatusToSentlyCode(status: number): SentlyErrorCode; /** * Map an SMTP response code and command to a stable sently error code. * * @param smtpCode - Three-digit SMTP response code (0 for local/parse errors) * @param command - SMTP command that failed * @returns Machine-readable error code */ export declare function smtpCodeToSentlyCode(smtpCode: number, command: string): SentlyErrorCode;