I have the following function that returns a string:
public static string GetFormattedErrorMessage(this Exception e)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
var exError = e.Message;
if (e.InnerException != null)
{
exError += "<br>" + e.InnerException.Message;
if (e.InnerException.InnerException != null)
{
exError += "<br>" + e.InnerException.InnerException.Message;
}
}
return exError;
}
Can someone help and tell me how I could make this same function return a IEnumerable<string>
with just one element?
public static IEnumerable<string> GetFormattedErrorMessage(this Exception e)
{
if (e == null)
{
throw new ArgumentNullException("e");
}
var exError = e.Message;
if (e.InnerException != null)
{
exError += "<br>" + e.InnerException.Message;
if (e.InnerException.InnerException != null)
{
exError += "<br>" + e.InnerException.InnerException.Message;
}
}
yield return exError;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With