Skip to content

Error handling and raw responses

Handle AdminApiError, cancellation, empty responses, and response metadata.

Updated View as Markdown
Audience: application-backendPlane: adminAuth: management-keyStatus: beta

Generated methods throw AdminApiError for non-success HTTP responses.

import { AdminApiError } from '@nexus/sdk-typescript';

try {
  await nexus.getWorkspace({ path: { workspaceId } });
} catch (error) {
  if (error instanceof AdminApiError) {
    console.error(error.status, error.body);
  }
  throw error;
}

AdminApiError retains status, the Web Standard Response, and the parsed response body. JSON bodies are parsed only when Content-Type contains json; empty 204/205 responses become undefined.

Raw response metadata

Use requestRaw(operationId, input, options) when the caller also needs headers or status:

const { data, response } = await nexus.requestRaw(
  'getWorkspace',
  { path: { workspaceId } },
  { signal: abortController.signal },
);

The SDK does not retry, reinterpret stable error codes, or hide cancellation. Pass an AbortSignal and make retry decisions at the application boundary.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close