Skip to content
CoreErrors

Errors

Reference for the Result type and the seven error kinds every verb can return.

Every verb resolves to a Result. Provider failures never throw. Match on error.kind to decide what to do:

const result = await docs.query({ vector, topK: 5 });

if (!result.ok) {
  switch (result.error.kind) {
    case "not_found":
      return [];
    case "unsupported":
      return fallback(result.error.feature);
    default:
      throw new Error(result.error.message);
  }
}

return result.value;

Kinds

error.kind is one of:

KindMeaning
not_foundThe index does not exist. Carries name.
already_existscreateIndex found an existing index. Carries name.
invalid_argumentThe provider rejected the request: wrong dimension, bad id, or bad metadata.
unsupportedThe provider cannot do this. Carries feature, for example deleteByFilter on Pinecone serverless, or a vecstore_ function that Supabase has no install for.
unauthorizedBad credentials or a missing permission.
connectionThe provider was unreachable or timed out.
providerAnything else. cause holds the original error.

Every error also carries provider ("qdrant", "pgvector", "pinecone", "supabase", "upstash", "vectorize", or "redis") and message.

Result type

type Result<T, E> =
  | { readonly ok: true; readonly value: T }
  | { readonly ok: false; readonly error: E };

The package exports the ok and err constructors for tests and fakes.

On this page