Skip to content

Errors

The raw client throws typed errors. All of them extend SdkError. Session actions never throw: they put these same errors in state.

SdkError
├── NetworkError
├── TimeoutError
├── AbortError
├── AffordanceUnavailableError
└── ApiError
├── UnauthorizedError 401
├── NotFoundError 404
├── ValidationError 422
└── ServerError 5xx
└── QuoteFailedError
  • requestId: the request’s correlation id. Quote it to support.
  • attempts: how many attempts were made.
  • cause: the underlying error.

The request didn’t complete: the network failed, a timeout passed, or you aborted with a signal.

The server didn’t offer the link or template the call needs. For example, quote.select() on a referred quote.

A non-2xx response.

  • status: the HTTP status.
  • body: the parsed body.
  • retryAfterMs: from Retry-After, when sent.

The quote set failed. Extends ServerError.

  • retry(options?): re-queue quoting. Returns a fresh questionnaire.
  • amend: the questionnaire’s amend link.
  • isSdkError(e), isApiError(e): type guards.
import { isApiError, QuoteFailedError, UnauthorizedError } from '@partner-sdk/core';
try {
const quoteSet = await q.quotes.wait();
} catch (e) {
if (e instanceof QuoteFailedError) {
const retried = await e.retry();
} else if (e instanceof UnauthorizedError) {
// check your API key
} else if (isApiError(e)) {
log('quote error', e.status, e.requestId); // never log answers
} else {
throw e;
}
}