/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { UnstructuredClientError } from "./unstructuredclienterror.js"; export type ServerErrorData = { detail?: string | undefined; }; export class ServerError extends UnstructuredClientError { detail?: string | undefined; /** The original data that was passed to this error instance. */ data$: ServerErrorData; constructor( err: ServerErrorData, 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; this.name = "ServerError"; } } /** @internal */ export const ServerError$inboundSchema: z.ZodType< ServerError, z.ZodTypeDef, unknown > = z.object({ detail: z.string().optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ServerError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type ServerError$Outbound = { detail?: string | undefined; }; /** @internal */ export const ServerError$outboundSchema: z.ZodType< ServerError$Outbound, z.ZodTypeDef, ServerError > = z.instanceof(ServerError) .transform(v => v.data$) .pipe(z.object({ detail: z.string().optional(), }));