Skip to content

mapError

function mapError(err, errors?): Response;

Defined in: src/server/http.ts:129

Map an error to a response:

  1. HttpError → its status and extras.
  2. An entry of errors matching the error’s name.
  3. Built-ins (each overridable by an errors entry of the same name): HookDeniedError (any bundle) → its status, code: "HOOK_DENIED"; a kit TokenError, or any error named *TokenError (PortalTokenError, ViewerTokenError from another bundle) → 401 code: "TOKEN"; ValidationError → 400 code: "VALIDATION" with errors; SyntaxError → 400 “Invalid JSON body”.
  4. Anything else → 500 with the error message.
Parameter Type
err unknown
errors? ErrorMap

Response