Entity Framework و InnerException
نویسنده: ایمان محمدی
تاریخ: ۱۳۹۱/۰۵/۲۰ ۱۳:۵۴
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
catch (Exception ex)
{
StringBuilder errorMsg = new StringBuilder();
for (Exception current = ex; current != null; current = current.InnerException)
{
if (errorMsg.Length > 0)
errorMsg.Append("\n");
errorMsg.Append(current.Message.Replace("See the inner exception for details.", string.Empty));
}
// log
errorMsg.ToString();
}
public static string ExceptionToString(this Exception ex)
{
StringBuilder errorMsg = new StringBuilder();
for (Exception current = ex; current != null; current = current.InnerException)
{
if (errorMsg.Length > 0)
errorMsg.Append("\n");
errorMsg.Append(current.Message.
Replace("See the inner exception for details.", string.Empty));
}
return errorMsg.ToString();
}
catch (Exception ex)
{
// log
ex.ExceptionToString();
}