1010using IOriginalPrimitive = Jint . Native . IJsPrimitive ;
1111using OriginalCancellationConstraint = Jint . Constraints . CancellationConstraint ;
1212using OriginalDebuggerEventHandler = Jint . Runtime . Debugger . DebugHandler . DebugEventHandler ;
13+ using OriginalDebuggerExceptionThrownEventHandler = Jint . Runtime . Debugger . DebugHandler . ExceptionThrownEventHandler ;
1314using OriginalDebuggerStatementHandlingMode = Jint . Runtime . Debugger . DebuggerStatementHandling ;
1415using OriginalEngine = Jint . Engine ;
1516using OriginalErrorPosition = Acornima . Position ;
16- using OriginalExecutionCanceledException = Jint . Runtime . ExecutionCanceledException ;
1717using OriginalException = Jint . JintException ;
18+ using OriginalExecutionCanceledException = Jint . Runtime . ExecutionCanceledException ;
1819using OriginalJavaScriptException = Jint . Runtime . JavaScriptException ;
1920using OriginalMemoryLimitExceededException = Jint . Runtime . MemoryLimitExceededException ;
2021using OriginalObjectInstance = Jint . Native . Object . ObjectInstance ;
@@ -90,6 +91,11 @@ public sealed class JintJsEngine : JsEngineBase
9091 /// </summary>
9192 private OriginalDebuggerEventHandler _debuggerStepCallback ;
9293
94+ /// <summary>
95+ /// Debugger exception thrown callback
96+ /// </summary>
97+ private OriginalDebuggerExceptionThrownEventHandler _debuggerExceptionThrownCallback ;
98+
9399 /// <summary>
94100 /// Flag for whether to allow run the script in strict mode
95101 /// </summary>
@@ -125,6 +131,7 @@ public JintJsEngine(JintSettings settings)
125131 JintSettings jintSettings = settings ?? new JintSettings ( ) ;
126132 _debuggerBreakCallback = jintSettings . DebuggerBreakCallback ;
127133 _debuggerStepCallback = jintSettings . DebuggerStepCallback ;
134+ _debuggerExceptionThrownCallback = jintSettings . DebuggerExceptionThrownCallback ;
128135 var debuggerStatementHandlingMode = Utils . GetEnumFromOtherEnum < JsDebuggerStatementHandlingMode , OriginalDebuggerStatementHandlingMode > (
129136 jintSettings . DebuggerStatementHandlingMode ) ;
130137
@@ -175,6 +182,10 @@ public JintJsEngine(JintSettings settings)
175182 {
176183 _jsEngine . Debugger . Step += _debuggerStepCallback ;
177184 }
185+ if ( _debuggerExceptionThrownCallback is not null )
186+ {
187+ _jsEngine . Debugger . ExceptionThrown += _debuggerExceptionThrownCallback ;
188+ }
178189 _strictMode = settings . StrictMode ;
179190 }
180191 catch ( Exception e )
@@ -709,6 +720,11 @@ public override void Dispose()
709720 {
710721 if ( _jsEngine is not null )
711722 {
723+ if ( _debuggerExceptionThrownCallback is not null )
724+ {
725+ _jsEngine . Debugger . ExceptionThrown -= _debuggerExceptionThrownCallback ;
726+ }
727+
712728 if ( _debuggerStepCallback is not null )
713729 {
714730 _jsEngine . Debugger . Step -= _debuggerStepCallback ;
@@ -723,6 +739,7 @@ public override void Dispose()
723739 _jsEngine = null ;
724740 }
725741
742+ _debuggerExceptionThrownCallback = null ;
726743 _debuggerStepCallback = null ;
727744 _debuggerBreakCallback = null ;
728745 _cancellationConstraint = null ;
0 commit comments