Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 2x 2x | import { z } from 'zod'
// One error body for every endpoint (design G19). `code` stays a string so an older client
// still parses a body that carries a code added after it was built.
export const ApiErrorSchema = z.object({
code: z.string(),
message: z.string(),
requestId: z.string(),
})
export type ApiError = z.infer<typeof ApiErrorSchema>
// The codes every endpoint can answer with. A route adds its own (such as mfa_required) beside these.
export const ERROR_CODE = {
invalidRequest: 'invalid_request',
unauthenticated: 'unauthenticated',
forbidden: 'forbidden',
notFound: 'not_found',
conflict: 'conflict',
rateLimited: 'rate_limited',
internal: 'internal',
} as const
export type ErrorCode = (typeof ERROR_CODE)[keyof typeof ERROR_CODE]
|