"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TechnicalError = void 0;
const SERVICE_NAME = process.env.SERVICE_NAME || 'SERVICE_NAME_NOT_DEFINED';
class TechnicalError extends Error {
    constructor(httpStatus, shouldTriggerInvestigation = true, message) {
        super(message);
        this.httpStatus = httpStatus;
        this.shouldTriggerInvestigation = shouldTriggerInvestigation;
        this.message = message;
        this.httpStatus = httpStatus;
        this.shouldTriggerInvestigation = shouldTriggerInvestigation;
    }
    static genericError(status, message) {
        return new TechnicalError(status, false, message);
    }
    static internalServerError(message) {
        return new TechnicalError(500, true, message);
    }
    static testOnlyFunctionWasCalled(functionName) {
        return new TechnicalError(500, true, `Test only function was called: ${functionName}`);
    }
    static emptySqsMessages() {
        return new TechnicalError(400, true, `No SQS Messages in body`);
    }
    static noAuthHeaderInEvent() {
        return new TechnicalError(400, true, `No Authentication header found in api gateway event`);
    }
    static actionNotAuthorized(details = '', shouldTriggerInvestigation = true) {
        return new TechnicalError(401, shouldTriggerInvestigation, 'Not Authorized' + (details === '' ? '.' : `: ${details}`));
    }
    static authorizerRequestSigningKeyNotAccessible(details) {
        return new TechnicalError(500, true, `Unable to sign auth verification request: ${details}`);
    }
    static cannotExtractAuthIdentityFromGatewayEvent(details) {
        return new TechnicalError(400, true, `Cannot extract auth identity from gateway event: ${details}`);
    }
    static unableToParseJson(jsonString) {
        return new TechnicalError(406, false, `Unable to parse JSON string: ${jsonString}`);
    }
    static invalidLambdaEvent(event) {
        return new TechnicalError(400, true, `Invalid Event received, unable to route it: ${JSON.stringify(event)}`);
    }
    static requestTimeout() {
        return new TechnicalError(408, true, `Request timed out`);
    }
    toString() {
        return `TechnicalError in ${SERVICE_NAME}: ${this.message}`;
    }
    toErrorObject() {
        return {
            message: this.message,
            httpStatus: this.httpStatus,
            shouldTriggerInvestigation: this.shouldTriggerInvestigation,
        };
    }
}
exports.TechnicalError = TechnicalError;
//# sourceMappingURL=TechnicalError.js.map