Created
September 4, 2016 23:32
-
-
Save ericelliott/6799ea2d18f4132eee8adc3f25822212 to your computer and use it in GitHub Desktop.
Capturing Unhandled Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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