Skip to content

Commit ee254b9

Browse files
author
David Karlaš
authored
Merge pull request #92 from JetBrains/onRunProperExceptionHandling
Handling exceptions in OnRun() before ForceExit
2 parents 2c1ca37 + 42b4668 commit ee254b9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Mono.Debugging/Mono.Debugging.Client/DebuggerSession.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ public void Run (DebuggerStartInfo startInfo, DebuggerSessionOptions options)
328328
try {
329329
OnRun (startInfo);
330330
} catch (Exception ex) {
331+
// should handle exception before raising Exit event because HandleException may ignore exceptions in Exited state
332+
var exceptionHandled = HandleException (ex);
331333
ForceExit ();
332-
if (!HandleException (ex))
334+
if (!exceptionHandled)
333335
throw;
334336
}
335337
});
@@ -363,8 +365,10 @@ public void AttachToProcess (ProcessInfo proc, DebuggerSessionOptions options)
363365
OnAttachToProcess (proc.Id);
364366
attached = true;
365367
} catch (Exception ex) {
368+
// should handle exception before raising Exit event because HandleException may ignore exceptions in Exited state
369+
var exceptionHandled = HandleException (ex);
366370
ForceExit ();
367-
if (!HandleException (ex))
371+
if (!exceptionHandled)
368372
throw;
369373
}
370374
});
@@ -509,8 +513,10 @@ public void Finish ()
509513
try {
510514
OnFinish ();
511515
} catch (Exception ex) {
516+
// should handle exception before raising Exit event because HandleException may ignore exceptions in Exited state
517+
var exceptionHandled = HandleException (ex);
512518
ForceExit ();
513-
if (!HandleException (ex))
519+
if (!exceptionHandled)
514520
throw;
515521
}
516522
});

0 commit comments

Comments
 (0)