Js error monitoring

I am interested in tracking javascript errors and reporting errors with a call.

I am not interested in wrapping everything in try-catch blocks.

According to this article http://blog.errorception.com/2011/12/call-stacks-in-ie.html it is possible inside window.onerror to recursively call .caller for each function on the stack to find out the previous function on the stack "

I tried to get the column:

window.onerror = function(errorMsg, url, lineNumber) { var stk = [], clr = arguments.callee.caller; while(clr) { stk.push("" + clr); clr = clr.caller; } // Logging stk send_callstack_to_log(stk); } 

but only one step is possible, even if the column was much longer:

 (function() { function inside() {it.will.be.exception;}; function middle() {inside()}; function outside() {middle()} outside(); })(); 

One step is not interesting, because the onerror arguments give me even more information about this.

Yes, I tried using IE in accordance with the article mentioned above.

Note. I also tried to open an "ERRORCAEPTION" account to collect the error log. I tested it with IE and "ERRORCAEPTION" realized that the errors came from IE, but I can’t find the call information in the log I have.

+6
source share
5 answers

Unfortunately, this journal will not always be available, it lacks line numbers, you cannot rely on it.

Try https://qbaka.com

Qbaka automatically overloads a bunch of JavaScript functions, such as addEventListener , setTimeout , XMLHtppRequest , etc., so that errors that occur in callbacks are automatically wrapped with try-catch, and you will get stacks without changing the code.

+2
source

Take a look here: https://github.com/eriwen/javascript-stacktrace

What I use in Muscula is a service, for example, an error, besides its free.

+1
source

You can try the atatus , which provides javascript contextual error tracking: https://www.atatus.com/

+1
source

I wrote a program to monitor JS errors. maybe it will help.
github: https://github.com/a597873885/webfunny_monitor
website: https: www.webfunny.cn (this will be slow)

0
source

I wrote a program to monitor JS errors. maybe it will help.

I used three kinds of methods to catch exceptions, such as window.onerror, rewrite console.error and window.onunhandledrejection. That way I can get an Uncaught error, an unhandled promise rejection, and a custom error

Take a look here: https://github.com/a597873885/webfunny_monitor

or here: https: www.webfunny.cn

This will help

0
source

All Articles