/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import * as components from "../components/index.js"; import { SDKBaseError } from "./sdkbaseerror.js"; export type ErrorModelData = { /** * A human-readable explanation specific to this occurrence of the problem. */ detail?: string | undefined; /** * Optional list of individual error details */ errors?: Array | null | undefined; /** * A URI reference that identifies the specific occurrence of the problem. */ instance?: string | undefined; /** * HTTP status code */ status?: number | undefined; /** * A short, human-readable summary of the problem type. This value should not change between occurrences of the error. */ title?: string | undefined; /** * A URI reference to human-readable documentation for the error. */ type?: string | undefined; }; export class ErrorModel extends SDKBaseError { /** * A human-readable explanation specific to this occurrence of the problem. */ detail?: string | undefined; /** * Optional list of individual error details */ errors?: Array | null | undefined; /** * A URI reference that identifies the specific occurrence of the problem. */ instance?: string | undefined; /** * HTTP status code */ status?: number | undefined; /** * A short, human-readable summary of the problem type. This value should not change between occurrences of the error. */ title?: string | undefined; /** * A URI reference to human-readable documentation for the error. */ type?: string | undefined; /** The original data that was passed to this error instance. */ data$: ErrorModelData; constructor( err: ErrorModelData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.detail != null) this.detail = err.detail; if (err.errors != null) this.errors = err.errors; if (err.instance != null) this.instance = err.instance; if (err.status != null) this.status = err.status; if (err.title != null) this.title = err.title; if (err.type != null) this.type = err.type; this.name = "ErrorModel"; } } /** @internal */ export const ErrorModel$inboundSchema: z.ZodType< ErrorModel, z.ZodTypeDef, unknown > = z.object({ detail: z.string().optional(), errors: z.nullable(z.array(components.ErrorDetail$inboundSchema)).optional(), instance: z.string().optional(), status: z.number().int().optional(), title: z.string().optional(), type: z.string().default("about:blank"), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ErrorModel(v, { request: v.request$, response: v.response$, body: v.body$, }); });