"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NON_SB_ORG_UPDATE_ERROR = exports.ServiceUnavailableError = exports.FailedDependencyError = exports.UnprocessableContentError = exports.MethodNotAllowedError = exports.ConflictError = exports.RbacUnauthorizedError = exports.TooManyRequestsError = exports.BadGatewayError = exports.NotImplementedError = exports.InternalServerError = exports.RequestTimedOut = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.HttpError = void 0;
class HttpError extends Error {
    status;
    message;
    title;
    constructor(status, message, title) {
        super(message);
        this.status = status;
        this.message = message;
        this.title = title;
    }
}
exports.HttpError = HttpError;
class BadRequestError extends HttpError {
    constructor(message) {
        super(400, message, 'Bad request');
    }
}
exports.BadRequestError = BadRequestError;
// We should use UnauthorizedError defined in packages/server
class UnauthorizedError extends HttpError {
    constructor(message) {
        super(401, message, 'Unauthorized');
    }
}
exports.UnauthorizedError = UnauthorizedError;
class ForbiddenError extends HttpError {
    constructor(message = 'You do not have permission to perform this action.') {
        super(403, message, 'Forbidden');
    }
}
exports.ForbiddenError = ForbiddenError;
class NotFoundError extends HttpError {
    constructor(message) {
        super(404, message || 'Resource not found', 'Not found');
    }
}
exports.NotFoundError = NotFoundError;
class RequestTimedOut extends HttpError {
    constructor(message) {
        super(408, message || 'Request timed out', 'Request timeout');
    }
}
exports.RequestTimedOut = RequestTimedOut;
class InternalServerError extends HttpError {
    constructor(message) {
        super(500, message || 'Internal server error', 'Internal server error');
    }
}
exports.InternalServerError = InternalServerError;
class NotImplementedError extends HttpError {
    constructor(message) {
        super(501, message, 'Not implemented');
    }
}
exports.NotImplementedError = NotImplementedError;
class BadGatewayError extends HttpError {
    constructor(message) {
        super(502, message, 'Bad gateway');
    }
}
exports.BadGatewayError = BadGatewayError;
class TooManyRequestsError extends HttpError {
    constructor(message) {
        super(429, message, 'Too many requests');
    }
}
exports.TooManyRequestsError = TooManyRequestsError;
// to differenciate from other UnauthorizedError returned from agent
class RbacUnauthorizedError extends UnauthorizedError {
    constructor(message) {
        super(message);
    }
}
exports.RbacUnauthorizedError = RbacUnauthorizedError;
class ConflictError extends HttpError {
    constructor(message) {
        super(409, message, 'Conflict occurred.');
    }
}
exports.ConflictError = ConflictError;
class MethodNotAllowedError extends HttpError {
    constructor(message) {
        super(405, message || 'Method Not Allowed', 'Method Not Allowed');
    }
}
exports.MethodNotAllowedError = MethodNotAllowedError;
class UnprocessableContentError extends HttpError {
    constructor(message) {
        super(422, message || 'Unprocessable Content', 'Unprocessable Content');
    }
}
exports.UnprocessableContentError = UnprocessableContentError;
class FailedDependencyError extends HttpError {
    constructor(message) {
        super(424, message, 'Failed Dependency');
    }
}
exports.FailedDependencyError = FailedDependencyError;
class ServiceUnavailableError extends HttpError {
    constructor(message) {
        super(503, message || 'Service Unavailable', 'Service Unavailable');
    }
}
exports.ServiceUnavailableError = ServiceUnavailableError;
exports.NON_SB_ORG_UPDATE_ERROR = 'Superblocks user cannot update non-Superblocks organization without explicit flag.';
//# sourceMappingURL=http.js.map