public void Record() { var ex = new TestException1("outer", new TestException2()); exceptionRecorder.Record(TestClass.MethodInfo1, ex); var exceptionData = new VSIExceptionData { CatchSite = TestClass.MethodInfo1.GetProto() }; exceptionData.ExceptionsChain.Add( new VSIExceptionData.Types.Exception { ExceptionType = typeof(TestException1).GetProto() }); exceptionData.ExceptionsChain.Add( new VSIExceptionData.Types.Exception { ExceptionType = typeof(TestException2).GetProto() }); var logEvent = new DeveloperLogEvent { StatusCode = DeveloperEventStatus.Types.Code.InternalError }; logEvent.ExceptionsData.Add(exceptionData); fakeMetrics.Received().RecordEvent( DeveloperEventType.Types.Type.VsiException, logEvent); }
void RecordExceptionChain(Exception ex, VSIExceptionData data) { for (uint i = 0; i < maxExceptionsChainLength && ex != null; i++) { var exData = new VSIExceptionData.Types.Exception(); exData.ExceptionType = ex.GetType().GetProto(); // TODO: record the exception stack trace. data.ExceptionsChain.Add(exData); ex = ex.InnerException; } if (ex != null) { data.ExceptionsChain.Add( new VSIExceptionData.Types.Exception { ExceptionType = typeof(ChainTooLongException).GetProto() }); } }
public void Record(MethodBase callSite, Exception ex) { if (callSite == null) { throw new ArgumentNullException(nameof(callSite)); } if (ex == null) { throw new ArgumentNullException(nameof(ex)); } var data = new VSIExceptionData(); data.CatchSite = callSite.GetProto(); RecordExceptionChain(ex, data); var logEvent = new DeveloperLogEvent(); logEvent.ExceptionsData.Add(data); logEvent.MergeFrom(ExceptionHelper.RecordException(ex)); metrics.RecordEvent(DeveloperEventType.Types.Type.VsiException, logEvent); }
static bool ExceptionChainOverflowRecorded(VSIExceptionData data) { return(data.ExceptionsChain.Count == MaxExceptionsChainLength + 1 && data.ExceptionsChain[(int)MaxExceptionsChainLength].ExceptionType.Equals( typeof(ExceptionRecorder.ChainTooLongException).GetProto())); }