/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import * as components from "../components/index.js"; export type HTTPValidationErrorData = { detail?: Array | undefined; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse?: Response | undefined; }; export class HTTPValidationError extends Error { detail?: Array | undefined; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse?: Response | undefined; /** The original data that was passed to this error instance. */ data$: HTTPValidationErrorData; constructor(err: HTTPValidationErrorData) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message); this.data$ = err; if (err.detail != null) this.detail = err.detail; if (err.rawResponse != null) this.rawResponse = err.rawResponse; this.name = "HTTPValidationError"; } } /** @internal */ export const HTTPValidationError$inboundSchema: z.ZodType< HTTPValidationError, z.ZodTypeDef, unknown > = z.object({ detail: z.array(components.ValidationError$inboundSchema).optional(), RawResponse: z.instanceof(Response).optional(), }) .transform((v) => { const remapped = remap$(v, { "RawResponse": "rawResponse", }); return new HTTPValidationError(remapped); }); /** @internal */ export type HTTPValidationError$Outbound = { detail?: Array | undefined; RawResponse?: never | undefined; }; /** @internal */ export const HTTPValidationError$outboundSchema: z.ZodType< HTTPValidationError$Outbound, z.ZodTypeDef, HTTPValidationError > = z.instanceof(HTTPValidationError) .transform(v => v.data$) .pipe( z.object({ detail: z.array(components.ValidationError$outboundSchema).optional(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }).optional(), }).transform((v) => { return remap$(v, { rawResponse: "RawResponse", }); }), ); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace HTTPValidationError$ { /** @deprecated use `HTTPValidationError$inboundSchema` instead. */ export const inboundSchema = HTTPValidationError$inboundSchema; /** @deprecated use `HTTPValidationError$outboundSchema` instead. */ export const outboundSchema = HTTPValidationError$outboundSchema; /** @deprecated use `HTTPValidationError$Outbound` instead. */ export type Outbound = HTTPValidationError$Outbound; }