Skip to Content
Engineering11 Documentation 🔥

Error API

Standardized error handling with structured error data and type safety.

What It Does

The Error API provides a standardized error handling system that extends JavaScript Error with structured error data. It enables consistent error categorization, error chaining, and type-safe error handling across all Foundation services.

Key Capabilities

CapabilityDescription
Structured ErrorsE11Error interface with type, title, message, and additional data
Error TransformationConvert standard errors to E11Error format with context preservation
Error ChainingMaintain error context through multiple transformations
Type GuardsRuntime type checking with isE11Error() and isE11ErrorOfType()
Error CategorizationGroup errors by type identifier (e.g., ‘datastores/’, ‘cloudflare/‘)
Severity LevelsErrorTrackerLevel enum for error severity
Context PreservationTrack original messages and error data through transformations

E11ErrorData Structure

{ type: string // Categorized identifier title: string // Human-readable title message?: string // Descriptive message previousMessage?: string // Original error message previousErrorData?: E11ErrorData // Error chain context additionalData?: any // Custom metadata level?: ErrorTrackerLevel // Severity level }

Usage Patterns

Create New Error

throw e11Error({ type: 'cloudflare/missing-keys', title: 'Missing Signing Keys', message: 'Unable to retrieve signing keys' })

Convert Existing Error

try { // operation } catch (err) { throw toE11Error(err, { title: 'Upload Failed', type: 'cloudflare/upload-failed' }) }

Type Checking

if (isE11ErrorOfType(err, 'datastores/not-found')) { // Handle specific error type }

Exports

  • E11Error - Error interface
  • E11ErrorData - Error data structure
  • toE11Error() - Error conversion function
  • e11Error() - Error factory function
  • isE11Error() - Type guard
  • isE11ErrorOfType() - Type-specific guard
  • ErrorTrackerLevel - Severity enum

Common Use Cases

  • Standardize error handling across microservices
  • Track error types for monitoring
  • Preserve error context through layers
  • Type-safe error handling
  • Custom error classes
  • Error categorization for reporting

What Customers Don’t Have to Build

  • Structured error format
  • Error transformation logic
  • Error chaining infrastructure
  • Type guard utilities
  • Error categorization system
  • Context preservation
  • Standardized error interfaces
Last updated on