From 2f55e03b36b129371ccd491f892c15e41edc2b6e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 16 May 2015 02:24:18 +0400 Subject: [PATCH 1/2] add a way to group raygun errors with parametrized messages --- plugins/c9.ide.errorhandler/raygun.js | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plugins/c9.ide.errorhandler/raygun.js b/plugins/c9.ide.errorhandler/raygun.js index 9931997f..63aa3f59 100644 --- a/plugins/c9.ide.errorhandler/raygun.js +++ b/plugins/c9.ide.errorhandler/raygun.js @@ -1422,6 +1422,19 @@ window.TraceKit = TraceKit; 'Script error.': {}, 'DealPly is not defined': { factor: 10e5 } }; + var groupedErrors = [{ + regex: /^((?:Project|User) with id ')(\d+)(' does not exist)/i, + pullOut: { 1: 'id' } + }, { + regex: /^(Failed to execute 'send' on 'XMLHttpRequest': Failed to load)([\s\S]*)/i, + pullOut: { 1: 'url' } + }, { + regex: /^(Cannot GET \/)([\s\S]*)/i, + pullOut: { 1: 'url' } + }, { + regex: /^(Error whilst parsing: Unexpected end whilst parsing xpath \/)([\s\S]*)/i, + pullOut: { 1: 'apfStuff' } + }]; function processUnhandledException(stackTrace, options) { var stack = [], qs = {}; @@ -1477,6 +1490,22 @@ window.TraceKit = TraceKit; // c9! var message = custom_message || stackTrace.message || options.status || 'Error with empty message'; + + groupedErrors.some(function(g) { + if (g.regex.test(message)) { + var parts = message.split(g.regex); + message = ""; + parts.forEach(function(p, i) { + if (g.pullOut[i - 1]) { + finalCustomData[g.pullOut[i - 1]] = p; + } else { + message += p; + } + }); + return true; + } + }); + if (blackListedErrors.hasOwnProperty(message)) { var count = (blackListedErrors[message].count || 0) + 1; blackListedErrors[message].count = count; From a325395a44f765c21a9e0a065b12e884a519b926 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 16 May 2015 02:51:02 +0400 Subject: [PATCH 2/2] if error without stack is logged add stack of the caller --- plugins/c9.ide.errorhandler/raygun_error_handler.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/c9.ide.errorhandler/raygun_error_handler.js b/plugins/c9.ide.errorhandler/raygun_error_handler.js index 82ddc557..10eae39d 100644 --- a/plugins/c9.ide.errorhandler/raygun_error_handler.js +++ b/plugins/c9.ide.errorhandler/raygun_error_handler.js @@ -67,6 +67,8 @@ define(function(require, exports, module) { console.error(exception); if (customData) console.log(customData); + if (!exception.stack) + exception.stack = new Error().stack; Raygun.send(exception, customData, tags); }