/* * 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 { SDKError } from "./sdkerror.js"; /** * The uniform error envelope. `error` is a stable machine-readable code * * @remarks * (never an internal reason); `correlation_id` echoes the request's * `X-Correlation-ID` for log correlation. */ export type RepoErrorData = { correlationId: string; error: string; }; /** * The uniform error envelope. `error` is a stable machine-readable code * * @remarks * (never an internal reason); `correlation_id` echoes the request's * `X-Correlation-ID` for log correlation. */ export class RepoError extends SDKError { correlationId: string; error: string; /** The original data that was passed to this error instance. */ data$: RepoErrorData; constructor( err: RepoErrorData, 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; this.correlationId = err.correlationId; this.error = err.error; this.name = "RepoError"; } } /** @internal */ export const RepoError$inboundSchema: z.ZodType< RepoError, z.ZodTypeDef, unknown > = z.object({ correlation_id: z.string(), error: z.string(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { const remapped = remap$(v, { "correlation_id": "correlationId", }); return new RepoError(remapped, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type RepoError$Outbound = { correlation_id: string; error: string; }; /** @internal */ export const RepoError$outboundSchema: z.ZodType< RepoError$Outbound, z.ZodTypeDef, RepoError > = z.instanceof(RepoError) .transform(v => v.data$) .pipe( z.object({ correlationId: z.string(), error: z.string(), }).transform((v) => { return remap$(v, { correlationId: "correlation_id", }); }), );