/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { DubError } from "./duberror.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * A short code indicating the error code returned. */ export const InternalServerErrorCode = { InternalServerError: "internal_server_error", } as const; /** * A short code indicating the error code returned. */ export type InternalServerErrorCode = ClosedEnum< typeof InternalServerErrorCode >; export type InternalServerErrorError = { /** * A short code indicating the error code returned. */ code: InternalServerErrorCode; /** * A human readable explanation of what went wrong. */ message: string; /** * A link to our documentation with more details about this error code */ docUrl?: string | undefined; }; /** * The server has encountered a situation it does not know how to handle. */ export type InternalServerErrorData = { error: InternalServerErrorError; }; /** * The server has encountered a situation it does not know how to handle. */ export class InternalServerError extends DubError { error: InternalServerErrorError; /** 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.error?.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.error = err.error; this.name = "InternalServerError"; } } /** @internal */ export const InternalServerErrorCode$inboundSchema: z.ZodNativeEnum< typeof InternalServerErrorCode > = z.nativeEnum(InternalServerErrorCode); /** @internal */ export const InternalServerErrorError$inboundSchema: z.ZodType< InternalServerErrorError, z.ZodTypeDef, unknown > = z.object({ code: InternalServerErrorCode$inboundSchema, message: z.string(), doc_url: z.string().optional(), }).transform((v) => { return remap$(v, { "doc_url": "docUrl", }); }); export function internalServerErrorErrorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => InternalServerErrorError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'InternalServerErrorError' from JSON`, ); } /** @internal */ export const InternalServerError$inboundSchema: z.ZodType< InternalServerError, z.ZodTypeDef, unknown > = z.object({ error: z.lazy(() => InternalServerErrorError$inboundSchema), 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$, }); });