/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { EntityErrorObject, EntityErrorObject$inboundSchema, } from "../components/entityerrorobject.js"; import { GustoEmbeddedError } from "./gustoembeddederror.js"; /** * Unprocessable Entity * * @remarks * * This may happen when the body of your request contains errors such as `invalid_attribute_value`, or the request fails due to an `invalid_operation`. See the [Errors Categories](https://docs.gusto.com/embedded-payroll/docs/error-categories) guide for more details. */ export type UnprocessableEntityErrorData = { errors: Array; }; /** * Unprocessable Entity * * @remarks * * This may happen when the body of your request contains errors such as `invalid_attribute_value`, or the request fails due to an `invalid_operation`. See the [Errors Categories](https://docs.gusto.com/embedded-payroll/docs/error-categories) guide for more details. */ export class UnprocessableEntityError extends GustoEmbeddedError { errors: Array; /** The original data that was passed to this error instance. */ data$: UnprocessableEntityErrorData; constructor( err: UnprocessableEntityErrorData, 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.errors = err.errors; this.name = "UnprocessableEntityError"; } } /** @internal */ export const UnprocessableEntityError$inboundSchema: z.ZodType< UnprocessableEntityError, z.ZodTypeDef, unknown > = z.object({ errors: z.array(EntityErrorObject$inboundSchema), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new UnprocessableEntityError(v, { request: v.request$, response: v.response$, body: v.body$, }); });