Skip to content

Commit

Permalink
[debugproxy] Invoke CDP endpoint to report error to telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
mdh1418 committed Mar 5, 2024
1 parent 413ace6 commit cefae9b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/mono/browser/debugger/BrowserDebugProxy/MonoProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -1519,17 +1520,30 @@ private async Task<bool> OnEvaluateOnCallFrame(MessageId msg_id, int scopeId, st
catch (ReturnAsErrorException ree)
{
SendResponse(msg_id, AddCallStackInfoToException(ree.Error, context, scopeId), token);
SendExceptionToTelemetry(ree, msg_id, token);
}
catch (Exception e)
{
logger.LogDebug($"Error in EvaluateOnCallFrame for expression '{expression}' with '{e}.");
var exc = new ReturnAsErrorException(e.Message, e.GetType().Name);
SendResponse(msg_id, AddCallStackInfoToException(exc.Error, context, scopeId), token);
var ree = new ReturnAsErrorException(e.Message, e.GetType().Name);
SendResponse(msg_id, AddCallStackInfoToException(ree.Error, context, scopeId), token);
SendExceptionToTelemetry(ree, msg_id, token);
}

return true;
}

private void SendExceptionToTelemetry(ReturnAsErrorException ree, SessionId msg_id, CancellationToken token)
{
var exceptionWithCallStackInfo = $"{ree.Error}\n{new StackTrace(1, true)}";
JObject reportBlazorDebugError = JObject.FromObject(new
{
exceptionType = "uncaughtException",
error = $"{exceptionWithCallStackInfo}",
});
SendEvent(msg_id, "DotnetDebugger.reportBlazorDebugError", reportBlazorDebugError, token);
}

internal async Task<GetMembersResult> GetScopeProperties(SessionId msg_id, int scopeId, CancellationToken token)
{
try
Expand Down

0 comments on commit cefae9b

Please sign in to comment.