Emergy.Core.Models.Log.ExceptionLog.GetCausingException C# (CSharp) 메소드

GetCausingException() 공개 메소드

public GetCausingException ( Exception exception ) : Exception
exception System.Exception
리턴 System.Exception
        public Exception GetCausingException(Exception exception) => exception.InnerException != null ? GetCausingException(exception.InnerException) : exception;
    }

Usage Example

예제 #1
0
파일: LogMail.cs 프로젝트: gboduljak/Emergy
 private static string BuildBody(ExceptionLog log)
 {
     StringBuilder bodyBuilder = new StringBuilder();
     bodyBuilder.AppendLine("Error : \n");
     bodyBuilder.AppendLine($"Happened at : {DateTime.Now.ToShortDateString()}!\n");
     bodyBuilder.AppendLine($"Causing exception : {log.Exception.ToString()}!\n");
     bodyBuilder.AppendLine("Short description : \n");
     bodyBuilder.AppendLine($"\t Message: {log.Exception.Message} \n");
     bodyBuilder.AppendLine($"\t Data: {log.Exception.Data} \n");
     bodyBuilder.AppendLine($"\t Stack trace: {log.Exception.StackTrace} \n");
     bodyBuilder.AppendLine($"\t Inner exception: {log.GetCausingException(log.Exception).StackTrace} \n");
     return bodyBuilder.ToString();
 }