/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import * as components from "../components/index.js"; import { CloudinaryAssetMgmtError } from "./cloudinaryassetmgmterror.js"; export type ApiErrorData = { error: components.ApiErrorError; }; export class ApiError extends CloudinaryAssetMgmtError { error: components.ApiErrorError; /** The original data that was passed to this error instance. */ data$: ApiErrorData; constructor( err: ApiErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = err.error?.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.error = err.error; this.name = "ApiError"; } } /** @internal */ export const ApiError$inboundSchema: z.ZodType< ApiError, z.ZodTypeDef, unknown > = z.object({ error: z.lazy(() => components.ApiErrorError$inboundSchema), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new ApiError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type ApiError$Outbound = { error: components.ApiErrorError$Outbound; }; /** @internal */ export const ApiError$outboundSchema: z.ZodType< ApiError$Outbound, z.ZodTypeDef, ApiError > = z.instanceof(ApiError) .transform(v => v.data$) .pipe(z.object({ error: z.lazy(() => components.ApiErrorError$outboundSchema), })); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ApiError$ { /** @deprecated use `ApiError$inboundSchema` instead. */ export const inboundSchema = ApiError$inboundSchema; /** @deprecated use `ApiError$outboundSchema` instead. */ export const outboundSchema = ApiError$outboundSchema; /** @deprecated use `ApiError$Outbound` instead. */ export type Outbound = ApiError$Outbound; }