HEX
Server: LiteSpeed
System: Linux srv1.dhviews.com 5.14.0-570.23.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 24 11:27:16 EDT 2025 x86_64
User: bdedition (1723)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/local/apps/nodejs21/lib/node_modules/npm/node_modules/@sigstore/sign/dist/external/error.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkStatus = exports.HTTPError = void 0;
class HTTPError extends Error {
    constructor({ status, message, location, }) {
        super(`(${status}) ${message}`);
        this.statusCode = status;
        this.location = location;
    }
}
exports.HTTPError = HTTPError;
const checkStatus = async (response) => {
    if (response.ok) {
        return response;
    }
    else {
        let message = response.statusText;
        const location = response.headers?.get('Location') || undefined;
        const contentType = response.headers?.get('Content-Type');
        // If response type is JSON, try to parse the body for a message
        if (contentType?.includes('application/json')) {
            try {
                await response.json().then((body) => {
                    message = body.message;
                });
            }
            catch (e) {
                // ignore
            }
        }
        throw new HTTPError({
            status: response.status,
            message: message,
            location: location,
        });
    }
};
exports.checkStatus = checkStatus;