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