Skip to content

Commit

Permalink
Updated the window.onerror sample in bugLogClient.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Bowes committed Oct 31, 2014
1 parent 1db48f3 commit 2130630
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions client/bugLogClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@
}
// Method 2: Within a global error handler (no stacktrace)
window.onerror = function(message, file, line) {
BugLog.notifyService({
message: message,
extraInfo: 'Error occurred in: ' + file + ':' + line,
severity:"ERROR"
});
return true;
};
// UPDATED. Taken from Stackoverflow user Sam. See http://stackoverflow.com/a/10556743/112680
window.onerror = function(msg, url, line, col, error) {
// Note that col & error are new to the HTML 5 spec and may not be
// supported in every browser. It worked for me in Chrome.
var extra = !col ? '' : '\ncolumn: ' + col;
extra += !error ? '' : '\nerror: ' + error;
// You can view the information in an alert to see things working like this:
alert("Error: " + msg + "\nurl: " + url + "\nline: " + line + extra);
BugLog.notifyService({
message: "JS Error: "+msg,
error: "url: " + url + "<br>line: " + line + extra,
severity: "ERROR"
});
var suppressErrorAlert = true;
// If you return true, then error alerts (like in older versions of
// Internet Explorer) will be suppressed.
return suppressErrorAlert;
};
</script>
*/

Expand Down

0 comments on commit 2130630

Please sign in to comment.