Error Handling

All errors in Colibri extend ColibriError, providing consistent structure across the library: unique error codes, diagnostic information, and typed metadata.

Error Shape

Property
Type
Description

code

string

Unique identifier (e.g., "BTX_003")

message

string

Human-readable description

details

string?

Additional context

diagnostic

Diagnostic?

Root cause, suggestion, and reference links

meta

object?

Error-specific data (input, cause)

Catching Errors

Use ColibriError.is() to identify Colibri errors:

import { ColibriError } from "@colibri/core";

try {
  await pipeline.run({...});
} catch (error) {
  if (ColibriError.is(error)) {
    console.log(error.code);    // "BTX_003"
    console.log(error.message); // "Could not load source account!"
  }
}

Diagnostics

Errors include diagnostic information with actionable suggestions:

Handling Specific Errors

Each module exports its error classes under a namespace (e.g., BTX_ERRORS for build-transaction). Use instanceof for typed access:

Error classes are also indexed by code:

Next Steps

Last updated