public string Convert(ExceptionThrownMessage message) { string text = ExceptionInformationToString(message.Exception); text += InnerException(message.InnerExceptions); return text; }
private string MessageToText(ExceptionThrownMessage message) { var builder = new StringBuilder(); builder.AppendLine("Invocation: {0}".Inject(message.Exception.Invocation)); builder.AppendLine("Message: {0}".Inject(message.Exception.Message)); builder.AppendLine("StackTrace: {0}".Inject(message.Exception.StackTrace)); return builder.ToString(); }
public void Setup() { m_Exception = new ArgumentException("Test"); var information = new ExceptionInformation { Invocation = "Invocation", Message = m_Exception.Message, StackTrace = m_Exception.StackTrace }; m_Sut = new ExceptionThrownMessage { Exception = information }; }
public ExceptionThrownMessage CreateExceptionThrownMessage(IInvocation invocation, Exception exception) { ExceptionInformation outerException = CreateExceptionInformation(invocation, exception); var innerExceptions = new List <ExceptionInformation>(); CreateInnerExceptionInformations(innerExceptions, exception); var message = new ExceptionThrownMessage { Exception = outerException, InnerExceptions = innerExceptions.ToArray() }; return message; }
private void ExceptionThrownHandler(ExceptionThrownMessage message) { m_Logger.Debug(MessageToText(message)); }
public void Intercept_SendsExceptionMessage_WhenProceedThrows() { // Arrange var excpected = new ExceptionThrownMessage(); m_ExceptionMessageConverter.CreateExceptionThrownMessage(Arg.Any <IInvocation>(), Arg.Any <Exception>()) .Returns(excpected); m_Logger.IsErrorEnabled.Returns(true); m_Invocation.WhenForAnyArgs(x => x.Proceed()) .Do(x => { throw new Exception("Test"); }); // Act Assert.Throws <Exception>(() => m_Sut.Intercept(m_Invocation)); // Assert m_Bus.Received().PublishAsync(excpected); }