Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created September 4, 2016 23:32
Show Gist options
  • Save ericelliott/6799ea2d18f4132eee8adc3f25822212 to your computer and use it in GitHub Desktop.
Save ericelliott/6799ea2d18f4132eee8adc3f25822212 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