던져진 Exception의 모든 수준의 InnerException (s)으로 이동하기위한 LINQ 스타일 "짧은 손"코드를 작성하는 방법이 있습니까? 확장 함수 (아래 참조)를 호출하거나 Exception클래스를 상속하는 대신 제자리에 작성하는 것을 선호합니다 .
static class Extensions
{
public static string GetaAllMessages(this Exception exp)
{
string message = string.Empty;
Exception innerException = exp;
do
{
message = message + (string.IsNullOrEmpty(innerException.Message) ? string.Empty : innerException.Message);
innerException = innerException.InnerException;
}
while (innerException != null);
return message;
}
};