<commit_before>// Silence jslint errors about the "console" global
/*global console: true */

var blueslip = (function () {

var exports = {};

var reported_errors = {};
function report_error(msg, stack, opts) {
    opts = $.extend({}, {show_ui_msg: false}, opts);

    if (stack === undefined) {
        stack = 'No stacktrace available';
    }

    var key = msg + stack;
    if (reported_errors.hasOwnProperty(key)) {
        return;
    }

    $.ajax({
        type:     'POST',
        url:      '/json/report_error',
        dataType: 'json',
        data:     { message: msg, stacktrace: stack },
        timeout:  3*1000,
        success:  function () {
            reported_errors[key] = true;
            if (opts.show_ui_msg) {
                ui.report_message("Oops.  It seems something has gone wrong. " +
                                  "The error has been reported to the nice " +
                                  "folks at Humbug, but, in the mean time, " +
                                  "please try reloading the page.",
                                  $("#home-error"), "alert-error");
            }
        },
        error: function () {
            if (opts.show_ui_msg) {
                ui.report_message("Oops.  It seems something has gone wrong. " +
                                  "Please try reloading the page.",
                                  $("#home-error"), "alert-error");
            }
        }
    });
}

exports.log = function blueslip_log (msg) {
    console.log(msg);
};

exports.info = function blueslip_info (msg) {
    console.info(msg);
};

exports.warn = function blueslip_warn (msg) {
    console.warn(msg);
    if (debug_mode) {
        console.trace();
    }
};

exports.error = function blueslip_error (msg) {
    if (debug_mode) {
        throw new Error(msg);
    } else {
        console.error(msg);
        report_error(msg, Error().stack);
    }
};

exports.fatal = function blueslip_fatal (msg) {
    if (! debug_mode) {
        report_error(msg, Error().stack, {show_ui_msg: true});
    }

    throw new Error(msg);
};

return exports;
}());

/*global console: false */<commit_msg>blueslip: Throw a custom exception type<commit_after>// Silence jslint errors about the "console" global
/*global console: true */

var blueslip = (function () {

var exports = {};

var reported_errors = {};
function report_error(msg, stack, opts) {
    opts = $.extend({}, {show_ui_msg: false}, opts);

    if (stack === undefined) {
        stack = 'No stacktrace available';
    }

    var key = msg + stack;
    if (reported_errors.hasOwnProperty(key)) {
        return;
    }

    $.ajax({
        type:     'POST',
        url:      '/json/report_error',
        dataType: 'json',
        data:     { message: msg, stacktrace: stack },
        timeout:  3*1000,
        success:  function () {
            reported_errors[key] = true;
            if (opts.show_ui_msg) {
                ui.report_message("Oops.  It seems something has gone wrong. " +
                                  "The error has been reported to the nice " +
                                  "folks at Humbug, but, in the mean time, " +
                                  "please try reloading the page.",
                                  $("#home-error"), "alert-error");
            }
        },
        error: function () {
            if (opts.show_ui_msg) {
                ui.report_message("Oops.  It seems something has gone wrong. " +
                                  "Please try reloading the page.",
                                  $("#home-error"), "alert-error");
            }
        }
    });
}

function BlueslipError() {
    return Error.apply(this, arguments);
}

BlueslipError.prototype = Error.prototype;

exports.log = function blueslip_log (msg) {
    console.log(msg);
};

exports.info = function blueslip_info (msg) {
    console.info(msg);
};

exports.warn = function blueslip_warn (msg) {
    console.warn(msg);
    if (debug_mode) {
        console.trace();
    }
};

exports.error = function blueslip_error (msg) {
    if (debug_mode) {
        throw new BlueslipError(msg);
    } else {
        console.error(msg);
        report_error(msg, Error().stack);
    }
};

exports.fatal = function blueslip_fatal (msg) {
    if (! debug_mode) {
        report_error(msg, Error().stack, {show_ui_msg: true});
    }

    throw new BlueslipError(msg);
};

return exports;
}());

/*global console: false */
{'fraction_non_alphanumeric': 0.130522538685804, 'fraction_numerical': 0.002242655303879794, 'mean_word_length': 1.7719080174021131, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '898987', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1282, 'n_words': 328}