Skip to Content
Spec

Error

Envelope schema, error-code table and their types.

Usage

import { ERROR_CODE_STATUS, errorEnvelopeSchema, type ErrorCode } from "@dapplelight/signet-spec/error"

const status = (code: ErrorCode) => ERROR_CODE_STATUS[code]

errorEnvelopeSchema.parse({ success: false, error: "Not found", code: "NOT_FOUND" })
status("NOT_FOUND") // 404

The envelope is { success: false, error, code?, details?, requestId? }. details is { formErrors: string[], fieldErrors: Record<string, string[]> }.

API

ExportWhat it does
errorEnvelopeSchemaZod schema for the body of a failed response
ErrorEnvelopez.infer of the envelope schema
ERROR_CODE_STATUSEvery code mapped to its default HTTP status, in ERROR_CODES order
ERROR_CODESThe codes, as an array
ErrorCodeUnion of the codes
errorCodeSchemaz.enum of the codes
SPEC_VERSION"v1", the version written into the JSON files