I'm writing a bug reporter for my app. 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'd like to include the last javascript error. Is there any way to do this?
Right-click anywhere in the webpage and then select Inspect. Or, press F12 . DevTools opens next to the webpage. In the top right of DevTools, the Open Console to view errors button displays an error about the webpage.
Go to the screen where you are experiencing the error. In Chrome, navigate to View > Developer > JavaScript Console or More Tools > JavaScript Console or press Ctrl + Shift + J. The error console will open. If you don't see any errors try reloading the page.
Error.captureStackTrace() A non-standard V8 function that creates the stack property on an Error instance.
There are two types of JavaScript error: Syntax Error: Occurs when there is a mistake in the way the code is written; for example, a typo or missing character. Runtime error: Occurs when the script is unable to complete its instructions; for example, if a specified object cannot be found.
You could implement a function to capture errors by using window.onerror
(MDN docu). That way the last error could be stored in window.localStorage
or wherever you want and you could retrieve it again, when the bugreport is filled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With