The error every SDK function fails with, its fields, and every code the SDK itself gives.

import { SpaceError, isSpaceError } from "digitospace"

Every function in the SDK fails with a SpaceError. A function that returns a promise rejects with one. createSpace(), and the first use of space, throw one. To handle errors step by step, see Handle errors.

Fields

SpaceError extends Error, so it also has message, stack, and cause.

name"SpaceError"

Always SpaceError.

codeSpaceErrorCode

What went wrong, as a stable code. Branch on it. It is one of the SDK’s codes, or a code from the service.

messagestring

A sentence for a person, which may say what to do next. It may be reworded at any time, so never branch on it.

statusnumber

The HTTP status the service answered with, or 0 when the failure happened in the SDK, such as a value checked before sending or a network failure.

retryableboolean

Whether the same call could work if you try it again later. The SDK has already tried a call that is safe to repeat. See Retries.

requestIdstring | undefined

The ID of the request, when the service answered. Quote it when you ask us for help.

issuesIssue[]

For validation_failed, every field that is wrong. Empty for every other code.

resourcestring | undefined

For not_found, what is missing, when the service says, such as bucket or object.

causeunknown

The error underneath, when there is one, such as the runtime’s own network error.

Issue

Each issue names one field that is wrong.

fieldstring

The field, with dots for a field inside an object, such as target.url.

codestring

Why it is wrong, such as required or invalid.

messagestring

A sentence for a person, such as how the value should look.

isSpaceError()

isSpaceError(value: unknown): value is SpaceError

Whether a value is a SpaceError. After it, TypeScript knows the value’s fields.

stat.ts
import { isSpaceError, space } from "digitospace"

try {
  const file = await space.fs.stat("invoices/2026/0001.pdf")
  console.log(file.size)
} catch (error) {
  if (isSpaceError(error) && error.code === "not_found") console.log("No such file")
  else throw error
}

error instanceof SpaceError does the same.

Codes from the SDK

The SDK gives these codes itself, for failures before a call is sent, while it is under way, or after the answer arrives. Most have a status of 0, because no service answered.

Setting up

CodeStatusRetryableWhen
validation_failed0noAn option, path, ID, message, or setting is not in the right form. Nothing was sent. issues names each field
missing_api_key0noThe call needs a key and the client has none for its product. Set DIGITOSPACE_API_KEY, or pass apiKey or apiKeys
missing_project0noThe call needs a project and the client has none. Set DIGITOSPACE_PROJECT, or pass project
browser_not_allowed0noThe SDK is running in a web page. Call it from your server instead
unsupported_runtime0noThe runtime has no fetch. Pass one in the fetch option

Sending and answers

CodeStatusRetryableWhen
timeout0yesA try took longer than timeoutMs
aborted0noThe call’s signal was aborted
network_error0yesThe service could not be reached
unexpected_response0, or the statusnoThe answer was not JSON, or was not in the shape this version expects. Update digitospace

Files

CodeStatusRetryableWhen
file_too_large0nospace.fs.write was given more than 100,000,000 bytes. Nothing was sent
upload_failedThe statuswhen 500 or higherStorage did not accept the file’s bytes. The upload is cancelled
download_failedThe statuswhen 500 or higherStorage could not send the file. A file that is not there fails with not_found instead

Chats and task streams

CodeStatusRetryableWhen
stream_interrupted0yesThe stream ended before the answer finished
stream_consumed0noA task stream was read a second time. A task stream can be read once; a chat stream can be read again
answer_invalid0, or the statusyesThe answer was not JSON, or did not match the schema given to chat(). issues names each field

Verifying calls to your app

CodeStatusRetryableWhen
invalid_signature401noThe call or delivery is not signed by us, is signed for someone else, or is too old. The message says which
unexpected_job403noA scheduler call came from a job not in jobs
keys_unavailableThe status, or 0yesThe scheduler’s public keys could not be fetched to check a call

See Verify calls to your app.

Codes from the service

When the service refuses a call, its code passes through unchanged, with its status, requestId, issues, resource, and retryable. The message is the service’s own. So the codes in each product’s error reference are the codes you branch on:

Codes that every service shares, such as unauthenticated, forbidden, not_found, rate_limited, and unavailable, each have a page in Problems.

When an answer carries no code of its own, the SDK gives one from its status:

StatusCode
400invalid_request
401unauthenticated
403forbidden
404not_found
409conflict
413payload_too_large
422validation_failed
429rate_limited
500internal
502, 503, or 504unavailable
Any otherunexpected_response

Such an error is retryable when its status is 429, or 502 or higher.

An error the model sends partway through a chat stream ends the stream with that error’s code and a status of 0.

SpaceErrorCode

code has the type SpaceErrorCode: the most common codes, which your editor suggests, and any other string, because a service can add codes.

import type { SpaceErrorCode } from "digitospace"

Last updated