Skip to content Documentation index for agents (llms.txt)
Glotto Beta
Get started

Errors

A failed request throws a typed ApiError carrying the full context — status, method, path, response body, headers, and the request id:

import { Client, ApiError } from '@your-org/petstore';

try {
  await client.pets.createPet({ name: '' });
} catch (err) {
  if (err instanceof ApiError) {
    console.error(err.status);     // e.g. 422
    console.error(err.requestId);  // for support
    console.error(err.body);       // parsed response body
  }
}

The error message is "<method> <path> -> <status>: <body>", so it’s readable in logs without unwrapping. Subclasses per status family are generated when the spec models them.

Every SDK, same error model

The same catch-and-narrow shape is emitted in every language — these are the bytes glotto generate produced, each stamped with the checksum of the artifact it came from:

import { ApiError } from 'glotto-sdk';

try {
  // any client call
} catch (err) {
  if (err instanceof ApiError) {
    console.error(err.status, err.toString());
  }
}

regenerated + byte-diffed in CI a0f8af4b462c