Intercept JS errors ?
Posted: Tue Feb 12, 2019 10:37 am
Let's say i run a JS code with a syntax error. In which event i can get the error message ? It seems the error does not trigger the 'onConsoleMessage' event.
The forum for BriskBard users and CEF4Delphi / WebView4Delphi / WebUI4Delphi / WebUI4CSharp developers
https://www.briskbard.com/forum/
In this case a JS error will throw a Delphi exception ?salvadordf wrote: Tue Feb 12, 2019 11:01 am Use the GlobalCEFApp.OnUncaughtException event to catch exceptions globally.
That event is triggered in the render process only and you will need to set GlobalCEFApp.UncaughtExceptionStackSize to a value greater than 0 to enable it.
No. The JS error will only trigger the GlobalCEFApp.OnUncaughtException event in the render process.thefunkyjoint wrote: Wed Feb 13, 2019 11:21 amIn this case a JS error will throw a Delphi exception ?salvadordf wrote: Tue Feb 12, 2019 11:01 am Use the GlobalCEFApp.OnUncaughtException event to catch exceptions globally.
That event is triggered in the render process only and you will need to set GlobalCEFApp.UncaughtExceptionStackSize to a value greater than 0 to enable it.
Code: Select all
browser.SendProcessMessage(PID_BROWSER, msg);
GlobalCEFApp.OnUncaughtException is executed in the render process. You need to use the debugging techniques described here :mmontu wrote: Tue Oct 15, 2019 2:51 pm I have tried UncaughtExceptionStackSize with:
but seems that it´s not working. MyAppOnUncaughtException() it´s not being executed. There it´s an example with this feature working or there is some issue and should use Window.onerror?Code: Select all
GlobalCEFApp.UncaughtExceptionStackSize := 10; GlobalCEFApp.OnUncaughtException := MyAppOnUncaughtException;
I'm glad you could get the information you needed.mmontu wrote: Tue Oct 15, 2019 3:31 pm I ended up using TChromium.OnConsoleMessage and checking if Level=LOGSEVERITY_ERROR.
I 'got the Message, line and source.![]()