Skip to content

Instantly share code, notes, and snippets.

@AshikNesin
Forked from ericelliott/unhandled-exceptions.js
Created November 6, 2016 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshikNesin/6510148ef996aad5a3cb2fec476191cc to your computer and use it in GitHub Desktop.
Save AshikNesin/6510148ef996aad5a3cb2fec476191cc to your computer and use it in GitHub Desktop.
Capturing Unhandled Exceptions
window.onerror = function(message, file, line, column, error) {
error = error || {};
$.ajax({
method: 'POST',
url: 'https://yourapp.com/path/to/error/log',
data: JSON.stringify({
message: message,
file: file,
line: line,
column: column,
error: {
name: error.name,
message: error.message,
stack: error.stack
}
})
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment