/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { ClosedEnum } from "../types/enums.js"; import * as types from "../types/primitives.js"; import { VercelError } from "./vercelerror.js"; export const InternalServerErrorCode = { InternalServerError: "internal_server_error", } as const; export type InternalServerErrorCode = ClosedEnum< typeof InternalServerErrorCode >; export type InternalServerErrorData = { status: number; code: InternalServerErrorCode; message: string; }; export class InternalServerError extends VercelError { status: number; code: InternalServerErrorCode; /** The original data that was passed to this error instance. */ data$: InternalServerErrorData; constructor( err: InternalServerErrorData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = err.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.status = err.status; this.code = err.code; this.name = "InternalServerError"; } } /** @internal */ export const InternalServerErrorCode$inboundSchema: z.ZodNativeEnum< typeof InternalServerErrorCode > = z.nativeEnum(InternalServerErrorCode); /** @internal */ export const InternalServerErrorCode$outboundSchema: z.ZodNativeEnum< typeof InternalServerErrorCode > = InternalServerErrorCode$inboundSchema; /** @internal */ export const InternalServerError$inboundSchema: z.ZodType< InternalServerError, z.ZodTypeDef, unknown > = z.object({ status: types.number(), code: InternalServerErrorCode$inboundSchema, message: types.string(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new InternalServerError(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type InternalServerError$Outbound = { status: number; code: string; message: string; }; /** @internal */ export const InternalServerError$outboundSchema: z.ZodType< InternalServerError$Outbound, z.ZodTypeDef, InternalServerError > = z.instanceof(InternalServerError) .transform(v => v.data$) .pipe(z.object({ status: z.number(), code: InternalServerErrorCode$outboundSchema, message: z.string(), }));