/* * 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 * as models from "../index.js"; import { SDKError } from "./sdk-error.js"; /** * Runtime error response. */ export type ErrorResponseData = { error?: models.ErrorT | undefined; code?: string | undefined; message?: string | undefined; timestamp?: string | undefined; [additionalProperties: string]: unknown; }; /** * Runtime error response. */ export class ErrorResponse extends SDKError { error?: models.ErrorT | undefined; code?: string | undefined; timestamp?: 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 = 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; if (err.timestamp != null) this.timestamp = err.timestamp; this.name = "ErrorResponse"; } } /** @internal */ export const ErrorResponse$inboundSchema: z.ZodMiniType< ErrorResponse, unknown > = z.pipe( z.object({ error: types.optional(z.lazy(() => models.ErrorT$inboundSchema)), code: types.optional(types.string()), message: types.optional(types.string()), timestamp: 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 ErrorResponse(v, { request: v.request$, response: v.response$, body: v.body$, }); }), );