Esiste un modo per scrivere un codice "short hand" in stile LINQ per raggiungere tutti i livelli di InnerException di eccezione generata? Preferirei scriverlo sul posto invece di chiamare una funzione di estensione (come sotto) o ereditare la Exception
classe.
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;
}
};