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