|
If I run the host app under the VS debugger I can see the js exceptions, exposed via Jint.Runtime.JavaScriptException in C#, and when they hit there I can see everything I need. However, if I'm not running under a debugger, I want to be able to log that same information, but can't see any way of getting it. I can't catch that exception, as its already being caught somewhere in Jint. I already log js execution line-by-line via a DebugHandler which is great, I have a full post-mortem debugger hooked up to that log. But I need to see the JS exceptions. |
Replies: 1 comment 1 reply
|
Hi! We've added an Here's how to use it: var engine = new Engine(options => options.DebugMode());
engine.Debugger.ExceptionThrown += (sender, args) =>
{
// args.ThrownValue - the JS value that was thrown
// args.Location - source file, line, and column
// args.CallStack - full call stack at the throw point
Console.WriteLine($"JS Exception at line {args.Location.Start.Line}: {args.ThrownValue}");
};
engine.Execute(script);This works for:
The event only fires when See PR #2375. |
Hi! We've added an
ExceptionThrownevent to theDebugHandlerthat does exactly this — it fires for all JavaScript exceptions (both caught and uncaught), analogous to first-chance exception notifications in the .NET debugger.Here's how to use it:
This works for:
throwstatements