void LoadSymbolsCustomCommand(string guid, int id, object customIn, object customOut, ref bool cancelDefault) { if (guid != _loadSymbolsGuid || id != _loadSymbolsFromModuleId) { return; } try { _taskContext.ThrowIfNotOnMainThread(); _programs.ForEach(LoadSymbols); RefreshSymbolsLoadingStatus(); } catch (Exception e) { // Users will see that module is not loaded via Modules window, // thus not showing any extra messages. Trace.WriteLine($"Error while loading symbols: {e}"); if (_vsiService.DebuggerOptions[DebuggerOption.EXCEPTION_METRICS] == DebuggerOptionState.ENABLED) { SafeErrorUtil.SafelyLogError(() => { _exceptionRecorder.Record(MethodBase.GetCurrentMethod(), e); }, "Failed to record exception"); } } // Do not invoke the handler for the command. cancelDefault = true; }
public void Intercept(IInvocation invocation) { try { invocation.Proceed(); } catch (Exception ex) { SafeErrorUtil.SafelyLogError(() => { exceptionRecorder.Record(invocation.MethodInvocationTarget, ex); }, "Failed to record exception"); throw; } }
/// <summary> /// Records an exception using the caller of this method as the callsite. /// Does not throw exceptions. /// </summary> public static void SafelyRecordHere(this IExceptionRecorder recorder, Exception ex) { StackTrace stackTrace; try { // Create stack trace that skips the current frame. stackTrace = new StackTrace(1); } catch (Exception e) { Trace.WriteLine("Unable to capture stack trace: " + e.ToString()); return; } SafeErrorUtil.SafelyLogError(() => Record(recorder, ex, stackTrace), "Recording exception"); }
void RecordErrors(Action action) { try { action?.Invoke(); } catch (Exception e) { Trace.WriteLine($"Error processing NoSourceWindow: {e}"); if (_vsiService.DebuggerOptions[DebuggerOption.EXCEPTION_METRICS] == DebuggerOptionState.ENABLED) { SafeErrorUtil.SafelyLogError( () => { _exceptionRecorder.Record(MethodBase.GetCurrentMethod(), e); }, "Failed to record exception"); } } }
public void Intercept(IInvocation invocation) { long initialTimestampInMicro = _timeSource.GetTimestampUs() - _debugSessionStartTimestampUs; try { invocation.Proceed(); } finally { SafeErrorUtil.SafelyLogError(() => { long finalTimestampInMicro = _timeSource.GetTimestampUs() - _debugSessionStartTimestampUs; _methodInvocationRecorder.Record(invocation.MethodInvocationTarget, initialTimestampInMicro, finalTimestampInMicro); }, "Failed to record method invocation"); } }
public void SafelyLogError() { SafeErrorUtil.SafelyLogError(() => { throw new TestException(); }, "message"); Assert.That(logSpy.GetOutput(), Contains.Substring("message")); Assert.That(logSpy.GetOutput(), Contains.Substring("TestException")); }