<commit_before>/**
 * This error handler catches window.onerror and sends them to raygun.io
 *
 * @extends Plugin
 * @singleton
 */
define(function(require, exports, module) {
    "use strict";

    main.consumes = [
        "Plugin", "info", "metrics"
    ];
    main.provides = ["error_handler"];
    return main;

    function main(options, imports, register) {
        var Plugin = imports.Plugin;
        var info = imports.info;
        var metrics = imports.metrics;

        /***** Initialization *****/
        
        var Raygun = require("./raygun").Raygun;
        var apiKey = options.apiKey;
        var version = options.version;
        var revision = options.revision;
        
        var plugin = new Plugin("Ajax.org", main.consumes);

        var loaded = false;
        function load() {
            if (loaded) return false;
            loaded = true;
            
            // without apiKey raygun throws an error
            if (!apiKey) return;
            
            var user = info.getUser();
            var workspace = info.getWorkspace();
            
            Raygun.init(apiKey).attach().withCustomData(function(ex) {
                return {
                    user: {
                        id: user.id,
                        name: user.name,
                        email: user.email
                    },
                    workspace: {
                        id: workspace.id,
                        name: workspace.name,
                        contents: workspace.contents
                    },
                    revision: revision,
                    data: ex && ex.data
                };
            });
            Raygun.setUser(info.getUser().name);
            Raygun.setVersion(version + ".0");
        }
        
        function log(exception, customData, tags) {
            metrics.increment("errorhandler.log");
            if (typeof exception === "string")
                exception = new Error(exception);
            if (!exception)
                exception = new Error("Unspecified error");
            console.error(exception);
            if (customData)
                console.log(customData);
            Raygun.send(exception, customData, tags);
        }
        
        /***** Lifecycle *****/
        
        plugin.on("load", function(){
            load();
        });
        
        /***** Register and define API *****/
        
        plugin.freezePublicAPI({
            /** @deprecated Use log() instead. */
            reportError: log,
            log: log
        });
        
        register(null, { "error_handler" : plugin });
    }
});<commit_msg>if error without stack is logged add stack of the caller<commit_after>/**
 * This error handler catches window.onerror and sends them to raygun.io
 *
 * @extends Plugin
 * @singleton
 */
define(function(require, exports, module) {
    "use strict";

    main.consumes = [
        "Plugin", "info", "metrics"
    ];
    main.provides = ["error_handler"];
    return main;

    function main(options, imports, register) {
        var Plugin = imports.Plugin;
        var info = imports.info;
        var metrics = imports.metrics;

        /***** Initialization *****/
        
        var Raygun = require("./raygun").Raygun;
        var apiKey = options.apiKey;
        var version = options.version;
        var revision = options.revision;
        
        var plugin = new Plugin("Ajax.org", main.consumes);

        var loaded = false;
        function load() {
            if (loaded) return false;
            loaded = true;
            
            // without apiKey raygun throws an error
            if (!apiKey) return;
            
            var user = info.getUser();
            var workspace = info.getWorkspace();
            
            Raygun.init(apiKey).attach().withCustomData(function(ex) {
                return {
                    user: {
                        id: user.id,
                        name: user.name,
                        email: user.email
                    },
                    workspace: {
                        id: workspace.id,
                        name: workspace.name,
                        contents: workspace.contents
                    },
                    revision: revision,
                    data: ex && ex.data
                };
            });
            Raygun.setUser(info.getUser().name);
            Raygun.setVersion(version + ".0");
        }
        
        function log(exception, customData, tags) {
            metrics.increment("errorhandler.log");
            if (typeof exception === "string")
                exception = new Error(exception);
            if (!exception)
                exception = new Error("Unspecified error");
            console.error(exception);
            if (customData)
                console.log(customData);
            if (!exception.stack)
                exception.stack = new Error().stack;
            Raygun.send(exception, customData, tags);
        }
        
        /***** Lifecycle *****/
        
        plugin.on("load", function(){
            load();
        });
        
        /***** Register and define API *****/
        
        plugin.freezePublicAPI({
            /** @deprecated Use log() instead. */
            reportError: log,
            log: log
        });
        
        register(null, { "error_handler" : plugin });
    }
});
{'fraction_non_alphanumeric': 0.11466372657111357, 'fraction_numerical': 0.0003675119441381845, 'mean_word_length': 1.2831375838926173, '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': '670966', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1299, 'n_words': 321}