"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerParseError = void 0;
const utils_js_1 = require("./utils.cjs");
/**
 * Thrown when failing to parse the response as JSON from the server.
 */
class ServerParseError extends Error {
    /** Determine if an error is an `ServerParseError` instance */
    static is(error) {
        return (0, utils_js_1.isBranded)(error, "ServerParseError");
    }
    /**
     * The server response.
     */
    response;
    /**
     * The status code returned from the server.
     */
    statusCode;
    /**
     * The raw body text returned in the server response.
     */
    bodyText;
    constructor(originalParseError, options) {
        super(originalParseError instanceof Error ?
            originalParseError.message
            : "Could not parse server response", { cause: originalParseError });
        this.name = "ServerParseError";
        this.response = options.response;
        this.statusCode = options.response.status;
        this.bodyText = options.bodyText;
        (0, utils_js_1.brand)(this);
        Object.setPrototypeOf(this, ServerParseError.prototype);
    }
}
exports.ServerParseError = ServerParseError;
//# sourceMappingURL=ServerParseError.cjs.map
