Skip to content
Discussion options

You must be logged in to vote

Hi! We've added an ExceptionThrown event to the DebugHandler that 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:

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:

  • Explicit throw statements
  • I…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@amp64
Comment options

Answer selected by lahma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants