/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import { S2Error } from "./s2error.js";
export class ErrorResponse extends S2Error {
    constructor(err, httpMeta) {
        const message = err.message || `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        if (err.code != null)
            this.code = err.code;
        this.name = "ErrorResponse";
    }
}
/** @internal */
export const ErrorResponse$inboundSchema = z.object({
    code: z.nullable(z.string()).optional(),
    message: z.string(),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new ErrorResponse(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const ErrorResponse$outboundSchema = z.instanceof(ErrorResponse)
    .transform(v => v.data$)
    .pipe(z.object({
    code: z.nullable(z.string()).optional(),
    message: z.string(),
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var ErrorResponse$;
(function (ErrorResponse$) {
    /** @deprecated use `ErrorResponse$inboundSchema` instead. */
    ErrorResponse$.inboundSchema = ErrorResponse$inboundSchema;
    /** @deprecated use `ErrorResponse$outboundSchema` instead. */
    ErrorResponse$.outboundSchema = ErrorResponse$outboundSchema;
})(ErrorResponse$ || (ErrorResponse$ = {}));
//# sourceMappingURL=errorresponse.js.map