/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { DuckyError } from "./duckyerror.js"; export type ErrorResponseData = { /** * Error message explaining the issue */ error?: string | undefined; }; export class ErrorResponse extends DuckyError { /** * Error message explaining the issue */ error?: string | undefined; /** The original data that was passed to this error instance. */ data$: ErrorResponseData; constructor( err: ErrorResponseData, 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.error != null) this.error = err.error; this.name = "ErrorResponse"; } } /** @internal */ export const ErrorResponse$inboundSchema: z.ZodType< ErrorResponse, z.ZodTypeDef, unknown > = z.object({ error: z.string().optional(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ErrorResponse(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type ErrorResponse$Outbound = { error?: string | undefined; }; /** @internal */ export const ErrorResponse$outboundSchema: z.ZodType< ErrorResponse$Outbound, z.ZodTypeDef, ErrorResponse > = z.instanceof(ErrorResponse) .transform(v => v.data$) .pipe(z.object({ error: z.string().optional(), })); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ErrorResponse$ { /** @deprecated use `ErrorResponse$inboundSchema` instead. */ export const inboundSchema = ErrorResponse$inboundSchema; /** @deprecated use `ErrorResponse$outboundSchema` instead. */ export const outboundSchema = ErrorResponse$outboundSchema; /** @deprecated use `ErrorResponse$Outbound` instead. */ export type Outbound = ErrorResponse$Outbound; }