<commit_before>/**
 * @file Error base class
 * @since 0.1.5
 */
/*#ifndef(UMD)*/
"use strict";
/*global _gpfExtend*/ // gpf.extend
/*global _gpfIgnore*/ // Helper to remove unused parameter warning
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*global _gpfStringCapitalize*/ // Capitalize the string
/*global _gpfStringReplaceEx*/ // String replacement using dictionary map
/*exported _gpfErrorDeclare*/ // Declare new gpf.Error names
/*#endif*/

/**
 * GPF Error class
 *
 * @constructor
 * @alias gpf.Error
 * @since 0.1.5
 */
var _GpfError = gpf.Error = function () {};

_GpfError.prototype = new Error();
_gpfExtend(_GpfError.prototype, /** @lends gpf.Error.prototype */ {

    constructor: _GpfError,

    /**
     * Error code
     *
     * @readonly
     * @since 0.1.5
     */
    code: 0,

    /**
     * Error name
     *
     * @readonly
     * @since 0.1.5
     */
    name: "Error",

    /**
     * Error message
     *
     * @readonly
     * @since 0.1.5
     */
    message: "",

    /**
     * Build message by substituting context variables
     *
     * @param {Object} context Dictionary of named keys
     * @since 0.1.5
     */
    _buildMessage: function (context) {
        var  replacements;
        if (context) {
            replacements = {};
            _gpfObjectForEach(context, function (value, key) {
                replacements["{" + key + "}"] = value.toString();
            });
            this.message = _gpfStringReplaceEx(this.message, replacements);
        }
    }

});

function _gpfErrorFactory (code, name, message) {
    function NewErrorClass (context) {
        this._buildMessage(context);
    }
    NewErrorClass.prototype = new _GpfError();
    _gpfExtend(NewErrorClass.prototype, {
        constructor: NewErrorClass,
        code: code,
        name: name,
        message: message
    });
    _GpfError[_gpfStringCapitalize(name)] = NewErrorClass;
    return function (context) {
        throw new NewErrorClass(context);
    };
}

/**
 * Generates an error class
 *
 * @param {Number} code Error code
 * @param {String} name Error name
 * @param {String} message Error message
 * @return {Function} New error class
 * @gpf:closure
 * @since 0.1.5
 */
function _gpfGenenerateErrorFunction (code, name, message) {<commit_msg>Fix issue with error on wscript<commit_after>/**
 * @file Error base class
 * @since 0.1.5
 */
/*#ifndef(UMD)*/
"use strict";
/*global _gpfExtend*/ // gpf.extend
/*global _gpfIgnore*/ // Helper to remove unused parameter warning
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*global _gpfStringCapitalize*/ // Capitalize the string
/*global _gpfStringReplaceEx*/ // String replacement using dictionary map
/*exported _gpfErrorDeclare*/ // Declare new gpf.Error names
/*#endif*/

/**
 * GPF Error class
 *
 * @constructor
 * @alias gpf.Error
 * @since 0.1.5
 */
var _GpfError = gpf.Error = function () {};

_GpfError.prototype = new Error();
_gpfExtend(_GpfError.prototype, /** @lends gpf.Error.prototype */ {

    constructor: _GpfError,

    /**
     * Error code
     *
     * @readonly
     * @since 0.1.5
     */
    code: 0,

    /**
     * Error name
     *
     * @readonly
     * @since 0.1.5
     */
    name: "Error",

    /**
     * Error message
     *
     * @readonly
     * @since 0.1.5
     */
    message: "",

    /**
     * Build message by substituting context variables
     *
     * @param {Object} context Dictionary of named keys
     * @since 0.1.5
     */
    _buildMessage: function (context) {
        var  replacements;
        if (context) {
            replacements = {};
            _gpfObjectForEach(context, function (value, key) {
                replacements["{" + key + "}"] = value.toString();
            });
            this.message = _gpfStringReplaceEx(this.message, replacements);
        }
    }

});

function _gpfErrorFactory (code, name, message) {
    function NewErrorClass (context) {
        this._buildMessage(context);
    }
    NewErrorClass.prototype = new _GpfError();
    _gpfExtend(NewErrorClass.prototype, {
        code: code,
        name: name,
        message: message
    });
    // constructor can't be enumerated with wscript
    NewErrorClass.prototype.constructor = NewErrorClass;
    _GpfError[_gpfStringCapitalize(name)] = NewErrorClass;
    return function (context) {
        throw new NewErrorClass(context);
    };
}

/**
 * Generates an error class
 *
 * @param {Number} code Error code
 * @param {String} name Error name
 * @param {String} message Error message
 * @return {Function} New error class
 * @gpf:closure
 * @since 0.1.5
 */
function _gpfGenenerateErrorFunction (code, name, message) {
{'fraction_non_alphanumeric': 0.131674111891087, 'fraction_numerical': 0.009359710699851096, 'mean_word_length': 2.4371345029239766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1943147', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1453, 'n_words': 375}