Skip to content

Instantly share code, notes, and snippets.

@shaggybb
Forked from ericelliott/unhandled-exceptions.js
Created January 28, 2018 16:18
Show Gist options
  • Save shaggybb/afd62a412999a41f51be8c9054b6e0b2 to your computer and use it in GitHub Desktop.
Save shaggybb/afd62a412999a41f51be8c9054b6e0b2 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