wrap StoppedEvent handler in try catch

This commit is contained in:
Matt Parker
2025-12-30 16:28:55 +10:00
parent 0aaec7e103
commit a198378999

View File

@@ -79,6 +79,8 @@ public class DebuggingService
responder.SetResponse(new HandshakeResponse(signatureResponse));
});
debugProtocolHost.RegisterEventType<StoppedEvent>(async void (@event) =>
{
try
{
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding); // The VS Code Debug Protocol throws if you try to send a request from the dispatcher thread
var additionalProperties = @event.AdditionalProperties;
@@ -108,6 +110,12 @@ public class DebuggingService
var continueRequest = new ContinueRequest { ThreadId = @event.ThreadId!.Value };
_debugProtocolHost.SendRequestSync(continueRequest);
}
}
catch (Exception e)
{
// TODO: use logger once this class is DI'd
Console.WriteLine($"Error handling StoppedEvent: {e}");
}
});
debugProtocolHost.VerifySynchronousOperationAllowed();
var initializeRequest = new InitializeRequest