コード例 #1
0
        private string ExceptionDetails(Exception contextException)
        {
            var sb = new StringBuilder();

            sb.AppendLine(contextException.AllExceptionMessages());
            sb.AppendLine("Stack Trace:");
            sb.AppendLine(contextException.StackTrace);
            return(sb.ToString());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static string LogMessage(this Exception ex)
 {
     return(string.Format("Exception Message: {0}.{1}Stack Trace: {2}.", ex.AllExceptionMessages(), Environment.NewLine, ex.StackTrace));
 }
コード例 #4
0
ファイル: Logger.cs プロジェクト: brunocampiol/BrunoCampiol
 public void LogException(Exception ex)
 {
     Console.Error.WriteLine($"[ERROR]: {ex.AllExceptionMessages()}, [STACK]: {ex.StackTrace}");
 }
コード例 #5
0
ファイル: Logger.cs プロジェクト: brunocampiol/BrunoCampiol
 public async Task LogExceptionAsync(Exception ex)
 {
     await Console.Error.WriteLineAsync($"[ERROR]: {ex.AllExceptionMessages()}, [STACK]: {ex.StackTrace}");
 }