Errors

What went wrong, told to the caller. Returned with fail().

Raised with

Added with

npx prongs add errors

Domains

Intents

Domains

Request

request.*

The caller’s request was wrong: unreadable, incomplete, or a value that breaks a rule. 400 or 422.

4004223 intents

Auth

auth.*

No valid credentials: nobody signed in, an expired session, a bad token or secret. 401.

4014 intents

Permission

permission.*

Valid credentials, but not allowed to do this. 403.

4031 intent

Record

record.*

The thing asked for is not there, as far as the caller may know. 404.

4041 intent

Conflict

conflict.*

The request clashes with the current state: it already exists, or it is not possible yet. 409.

4092 intents

Limit

limit.*

Too many requests, or an allowance used up. 429.

4291 intent

Failure

failure.*

Our fault or a dependency’s. The caller sees a generic message; the details are logged. 5xx.

5005025033 intents

Raising one

fail(intent, message?, options?) returns the Response: { ok: false, error, code } with the intent’s status. Name what went wrong; the intent sets the status, the message the caller sees, and any log it writes. Read the guide.

TS
// The request cannot be read: invalid JSON, the wrong content type
return fail('request.malformed', 'Invalid JSON.');

// A required field or parameter is absent
return fail('request.missing', 'Handle is required.');

// A field breaks a rule: too long, the wrong format, out of range
return fail('request.invalid', 'Use 1–32 lowercase letters, numbers, or hyphens.');

Looks

The statuses error intents are built from. Change a status here and every error built from it follows. Looks have no pages of their own; each is listed here with what it is built from and the intents built from it.

status.*

For registry authors

Starter intents. These are the intents prongs add errors puts in your registry, raised with fail(). Change the messages to suit your app, and the statuses through the status.* intents they are built from.