/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import * as types from "../../types/primitives.js"; import { SDKError } from "./sdk-error.js"; export type LegacyErrorData = { error?: string | undefined; code?: string | undefined; message?: string | undefined; [additionalProperties: string]: unknown; }; export class LegacyError extends SDKError { error?: string | undefined; code?: string | undefined; /** The original data that was passed to this error instance. */ data$: LegacyErrorData; constructor( err: LegacyErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = err.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; if (err.error != null) this.error = err.error; if (err.code != null) this.code = err.code; this.name = "LegacyError"; } } /** @internal */ export const LegacyError$inboundSchema: z.ZodMiniType = z .pipe( z.object({ error: types.optional(types.string()), code: types.optional(types.string()), message: types.optional(types.string()), request$: z.custom(x => x instanceof Request), response$: z.custom(x => x instanceof Response), body$: z.string(), }), z.transform((v) => { return new LegacyError(v, { request: v.request$, response: v.response$, body: v.body$, }); }), );