/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import * as components from "../components/index.js";
import { CloudinaryAnalysisError } from "./cloudinaryanalysiserror.js";
/**
 * Bad request
 */
export class ErrorResponse extends CloudinaryAnalysisError {
    constructor(err, httpMeta) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        if (err.error != null)
            this.error = err.error;
        this.name = "ErrorResponse";
    }
}
/** @internal */
export const ErrorResponse$inboundSchema = z.object({
    error: z.nullable(components.ErrorObject$inboundSchema).optional(),
    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({
    error: z.nullable(components.ErrorObject$outboundSchema).optional(),
}));
/**
 * @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