Email SDK
Reference

Errors

Reference for Email SDK error classes and retry flags.

Email SDK exports four error classes.

import {
  EmailProviderError,
  EmailProviderNotFoundError,
  EmailSdkError,
  EmailValidationError,
} from "@opencoredev/email-sdk";

Error fields

EmailSdkError includes:

FieldTypeNotes
codestringMachine-readable error code.
providerstringRouting name when available.
statusnumberHTTP status when available.
retryablebooleanWhether retry is reasonable.
detailsunknownAdapter response body or extra context.

Common errors

ErrorWhen it happens
EmailValidationErrorA message or client config is invalid.
EmailProviderNotFoundErrorThe selected adapter is not registered.
EmailProviderErrorAn adapter call fails.
EmailSdkErrorA general SDK-level failure occurs.

Retries and fallbacks

retryable means retrying the same adapter is reasonable. It is not required for fallback. After an adapter finally fails, Email SDK can advance to the next configured fallback adapter.

EmailValidationError from top-level message validation stops the send before adapter attempts. Adapter-specific unsupported-field validation can surface during an adapter attempt, so do not rely on fallback to fix an incompatible message shape. Choose fallback adapters that can represent the same fields your message uses.

When multiple attempted routes fail, Email SDK throws an EmailSdkError with code all_providers_failed and the collected failures in details.

Handling adapter errors

try {
  await email.send(message);
} catch (error) {
  if (error instanceof EmailProviderError && error.retryable) {
    // Queue a later retry, alert, or switch to another flow.
  }

  throw error;
}

On this page