import { brand, isBranded } from "./utils.js";
/**
 * Thrown when failing to parse the response as JSON from the server.
 */
export class ServerParseError extends Error {
    /** Determine if an error is an `ServerParseError` instance */
    static is(error) {
        return 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;
        brand(this);
        Object.setPrototypeOf(this, ServerParseError.prototype);
    }
}
//# sourceMappingURL=ServerParseError.js.map
