Skip to main content

Error Handling

All SDK methods throw a RagPackError when the server returns a non-2xx response or when a job fails.

Catching errors

import { RagPack, RagPackError } from "ragpack-js";

try {
await collection.findSimilar({ query: "..." });
} catch (err) {
if (err instanceof RagPackError) {
console.error(err.status, err.message);
}
}

RagPackError

PropertyTypeDescription
statusnumberHTTP status code returned by the server
messagestringHuman-readable error message

Common error codes

StatusCause
401Missing or invalid API key
404Collection or document not found
408waitUntilComplete timed out before the job finished
422Ingestion job failed — check job.error for details
500Unexpected server error