Skip to main content

Errors

Errors​

HTTP failures throw SourcingApiError. message is the status text. The response body is never copied into message.

Statusmessage
401Sign in again or check your sourcing credentials.
403You do not have permission to perform this action.
404The requested item was not found.
409This search changed. Reload it and try again.
429Too many requests. Wait and try again.
otherRequest failed (${status}).

When the body is a JSON object { "error": "…" } of at most 4000 characters, that string is detail. Any other body leaves detail unset.

import { SourcingApiError, errorMessage, isAbortError } from '@search-engine-sdk/core';

try {
await client.chats().get(id);
} catch (error) {
if (isAbortError(error)) return;
if (error instanceof SourcingApiError) {
show(error.detail ?? error.message);
return;
}
show(errorMessage(error));
}

errorMessage maps a SourcingError to its message, an abort to "The request was cancelled.", and anything else to a connection message. SourcingError.code is config, http, network, stream, or turn. A non-JSON success body uses code http. A redirect is rejected and surfaces as code network.