Skip to main content
The SDK throws typed errors you can catch and handle based on the error type.

Error types

ErrorCause
AuthenticationErrorInvalid or missing API token
AuthorizationErrorValid token but insufficient permissions
NotFoundErrorResource doesn’t exist or isn’t accessible
ValidationErrorInvalid request parameters
RateLimitErrorToo many requests
FeatureNotEnabledErrorFeature requires a plan upgrade
UpstreamErrorCarrier or terminal API is unavailable
Terminal49ErrorGeneric error fallback

Basic error handling

import {
  Terminal49Client,
  AuthenticationError,
  RateLimitError,
  NotFoundError,
} from '@terminal49/sdk';

const client = new Terminal49Client({
  apiToken: process.env.T49_API_TOKEN!,
});

try {
  await client.containers.get('container-uuid');
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API token');
  } else if (error instanceof NotFoundError) {
    console.error('Container not found');
  } else if (error instanceof RateLimitError) {
    console.error('Rate limited, retrying in 60s');
    await new Promise((resolve) => setTimeout(resolve, 60000));
  } else {
    throw error;
  }
}

Automatic retries

The SDK automatically retries 429 and 5xx responses with exponential backoff up to maxRetries (default: 2).
const client = new Terminal49Client({
  apiToken: process.env.T49_API_TOKEN!,
  maxRetries: 3,
});

Error properties

All SDK errors include:
PropertyTypeDescription
messagestringHuman-readable error description
statusnumberHTTP status code
detailsunknownRaw error payload from the API