Get the latest Javascript error

I am writing an error reporter for my application. When something goes wrong, the user fills out a form and describes the problem, and this is sent to the server. As part of the data collected in this form, I would like to include the latest javascript error. Is there any way to do this?

+8
javascript
source share
3 answers

You can implement a function to capture errors using window.onerror (

+5
source share

you can use window.onerror

 window.onerror = function(error, url, line) { //save errors here }; 
+6
source share

You can assign the window.onerror function and save the error information from the arguments.

+3
source share

All Articles