private string ExceptionDetails(Exception contextException) { var sb = new StringBuilder(); sb.AppendLine(contextException.AllExceptionMessages()); sb.AppendLine("Stack Trace:"); sb.AppendLine(contextException.StackTrace); return(sb.ToString()); }
public void TestAllExceptionMessages() { // Assemble Exception innerInnerException = new Exception("Inner Inner Exception Message"); Exception innerException = new Exception("Inner Exception Message", innerInnerException); Exception exception = new Exception("Exception Message", innerException); string expectedMessage = "(Exception): Exception Message (InnerException): Inner Exception Message (InnerException): Inner Inner Exception Message"; // Act string actualMessage = exception.AllExceptionMessages(); // Assert Assert.Equal(expectedMessage, actualMessage); }
public static string LogMessage(this Exception ex) { return(string.Format("Exception Message: {0}.{1}Stack Trace: {2}.", ex.AllExceptionMessages(), Environment.NewLine, ex.StackTrace)); }
public void LogException(Exception ex) { Console.Error.WriteLine($"[ERROR]: {ex.AllExceptionMessages()}, [STACK]: {ex.StackTrace}"); }
public async Task LogExceptionAsync(Exception ex) { await Console.Error.WriteLineAsync($"[ERROR]: {ex.AllExceptionMessages()}, [STACK]: {ex.StackTrace}"); }