Atılan İstisnanın tüm InnerException (ları) seviyelerine yürümek için LINQ tarzı "kısa el" kodu yazmanın bir yolu var mı? Bir uzantı işlevi çağırmak (aşağıdaki gibi) veya Exceptionsınıfı miras almak yerine yerinde yazmayı tercih ederim .
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;
}
};