Catch javascript errors

122 views
Skip to first unread message

Mihai Ciureanu

unread,
Apr 22, 2014, 9:57:58 AM4/22/14
to cef...@googlegroups.com
Hello.

I've been struggling to fin a method to catch javascript errors in the C# host application. Any idea how to do that?

Thank you.

Czarej Tomczak

unread,
Apr 23, 2014, 1:29:09 AM4/23/14
to cef...@googlegroups.com
Hi Mihai,
In CEF there is the OnUncaughtException callback that can handle v8 exceptions globally.

Or you can use pure javascript to catch errors using window.onerror event:

window.onerror = function (errorMessage, url, lineNumber) {}

Though, this one won't provide you stack trace. Also CEF v8 stack trace is lost when called from within onerror.

Best regards,
Czarek

Mihai Ciureanu

unread,
Apr 23, 2014, 4:16:22 AM4/23/14
to cef...@googlegroups.com
Thank you. I'm trying to do the same as I would do for a normal desktop application. In case of any unhandled exception show some message, log it, etc...  The errors that I encounter from time to time are either javascript errors or some browser errors - something happens to application cache, etc... (I use html5 application cache). I'll try with OnUncoughtException, thank you.
Reply all
Reply to author
Forward
0 new messages