"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadRequestError = exports.PaymentRequiredError = exports.ForbiddenError = exports.EntityNotFoundError = exports.DuplicateError = exports.EntityExpiredError = exports.InternalServerError = exports.NotImplementedError = exports.ServiceUnavailableError = exports.DfnsError = void 0;
class DfnsError extends Error {
    constructor(message, serviceName, causes = [], shouldTriggerInvestigation = true) {
        super(message);
        this.name = 'DfnsError';
        this.httpStatus = 500;
        this.shouldTriggerInvestigation = false;
        this.serviceName = 'SERVICE_NOT_DEFINED';
        this.causes = [];
        this.isDfnsError = true;
        this.serviceName = serviceName || process.env.SERVICE_NAME;
        this.shouldTriggerInvestigation = shouldTriggerInvestigation;
        this.causes = causes;
        if (typeof serviceName !== 'string') {
            this.serviceName = 'SERVICE_NOT_DEFINED';
            this.shouldTriggerInvestigation = true;
        }
    }
    toErrorObject() {
        const stackTrace = this.stack || '';
        return {
            name: this.name,
            serviceName: this.serviceName,
            message: this.message,
            causes: this.causes,
            shouldTriggerInvestigation: this.shouldTriggerInvestigation,
            httpStatus: this.httpStatus,
            stackTrace,
        };
    }
    toString() {
        return JSON.stringify(this.toErrorObject());
    }
}
exports.DfnsError = DfnsError;
class ServiceUnavailableError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'ServiceUnavailableError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 503;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Service Unavailable';
    }
}
exports.ServiceUnavailableError = ServiceUnavailableError;
class NotImplementedError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'NotImplementedError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 501;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Not Implemented';
    }
}
exports.NotImplementedError = NotImplementedError;
class InternalServerError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'InternalServerError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 500;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Internal Server Error';
    }
}
exports.InternalServerError = InternalServerError;
class EntityExpiredError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'EntityExpiredError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 410;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Resource Expired';
    }
}
exports.EntityExpiredError = EntityExpiredError;
class DuplicateError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'DuplicateError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 409;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Duplicate';
    }
}
exports.DuplicateError = DuplicateError;
class EntityNotFoundError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'EntityNotFoundError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 404;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Not Found';
    }
}
exports.EntityNotFoundError = EntityNotFoundError;
class ForbiddenError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'ForbiddenError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 403;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Access To Resource Not Allowed';
    }
}
exports.ForbiddenError = ForbiddenError;
class PaymentRequiredError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'PaymentRequiredError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 402;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Payment Required';
    }
}
exports.PaymentRequiredError = PaymentRequiredError;
class BadRequestError extends DfnsError {
    constructor() {
        super(...arguments);
        this.name = 'BadRequestError';
        // FIXME: Missing documentation for isDfnsError
        this.isDfnsError = true;
        // FIXME: Missing documentation for httpStatus
        this.httpStatus = 400;
        // FIXME: Missing documentation for errorName
        this.errorName = 'Bad Request';
    }
}
exports.BadRequestError = BadRequestError;
