"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapGroupingError = void 0;
var grp_errors_types_1 = require("../types/grp-errors.types");
var grouping_errors_dict_1 = require("./grouping-errors.dict");
var mapGroupingError = function (returnCode) {
    var returnCodeNumber = parseInt(returnCode);
    if (returnCodeNumber === 0)
        return null;
    if (isNaN(returnCodeNumber) && returnCode)
        return {
            code: 0,
            errorName: 'Erreur de groupage inconnue',
            scope: null,
            blockingErrorGroup: grp_errors_types_1.BlockingErrorGroup.IMPLEMENTATION_ERROR,
            description: "Ce code d'erreur n'a pas pu \u00EAtre transform\u00E9 en un code num\u00E9rique : ".concat(returnCode),
        };
    var groupingErrorInfo = grouping_errors_dict_1.groupingErrorDict[returnCodeNumber];
    if (!groupingErrorInfo && returnCode)
        return {
            code: returnCodeNumber,
            errorName: 'Erreur de groupage inconnue',
            scope: null,
            blockingErrorGroup: grp_errors_types_1.BlockingErrorGroup.IMPLEMENTATION_ERROR,
            description: 'Ce code d\'erreur n\'est pas connu dans le dictionnaire des erreurs de groupage',
        };
    return __assign({ code: returnCodeNumber }, groupingErrorInfo);
};
exports.mapGroupingError = mapGroupingError;
