Errors
Errors
HTTP failures throw SourcingApiError. message is the status text. The response body is never copied into message.
| Status | message |
|---|---|
| 401 | Sign in again or check your sourcing credentials. |
| 403 | You do not have permission to perform this action. |
| 404 | The requested item was not found. |
| 409 | This search changed. Reload it and try again. |
| 429 | Too many requests. Wait and try again. |
| other | Request 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.