public static class ExceptionExtensions
{
public static IEnumerable<Exception> GetAllExceptions(this Exception ex)
{
Exception currentEx = ex;
yield return currentEx;
while (currentEx.InnerException != null)
{
currentEx = currentEx.InnerException;
yield return currentEx;
}
} public static IEnumerable<string> GetAllExceptionAsString(this Exception ex)
{
Exception currentEx = ex;
yield return currentEx.ToString();
while (currentEx.InnerException != null)
{
currentEx = currentEx.InnerException;
yield return currentEx.ToString();
}
} public static IEnumerable<string> GetAllExceptionMessages(this Exception ex)
{
Exception currentEx = ex;
yield return currentEx.Message;
while (currentEx.InnerException != null)
{
currentEx = currentEx.InnerException;
yield return currentEx.Message;
}
}
}

ExceptionExtensions的更多相关文章

  1. 《Prism 5.0源码走读》UnityBootstrapper

    UnityBootstrapper (abstract class)继承自Bootstrapper(abstract)类, 在Prism.UnityExtensions.Desktop project ...

  2. 《Prism 5.0源码走读》Bootstrapper

    Prism框架需要在应用程序启动的时候进行一些初始化的工作,Bootstrapper就是来做这些的,是其切入点. Bootstrapper主要要做的事有:创建和配置module catalog,创建D ...

  3. 处理 InnerException 最佳方案?

    如何获取 innerException 内部错误信息 String innerMessage = (ex.InnerException != null) ? ex.InnerException.Mes ...

  4. [伟哥开源项目基金会](https://github.com/AspNetCoreFoundation)

    伟哥开源项目基金会 GitHub_base=> 伟哥开源项目基金会 该项目作者为伟哥,GitHub地址:https://github.com/amh1979: 该项目维护者为鸟窝,GitHub地 ...

  5. .NET中的异常处理机制(二)

    本文我们继续通过另一个例子来讲解在C#中如何捕捉异常并进行处理. 首先,我们新建一个控制台应用和一个Class Library Project.如下图所示. 图1 ConsoleUI应用 图2 Exc ...

  6. Managed Media Aggregation using Rtsp and Rtp

    his article was written almost 2 years ago, it's content may not reflect the latest state of the cod ...

随机推荐

  1. IE6低版本jQuery里的show和hide方法BUG

    公司内部一直在用的jQ的版本有些低,具体是哪个版本不太清楚,相关的东西都给删掉了,今天在做一个固定在页面右侧的导航的时候,IE6里出现了一个比较奇葩的问题.具体样子如下图: 收起是用定位left等于负 ...

  2. hgrjhgkjh

    #include<stdio.h> int step[5]={13,5,1,4,11}; int sum; int min=999; void ji() {  int i;  int j; ...

  3. go gomail

    package main //cmd: go get gopkg.in/gomail.v1 import ( "gopkg.in/gomail.v1" ) func main() ...

  4. Nginx配置(日志服务器中关于日志的产生)

    一:概括 1.需要配置的概括 定义日志格式 日志的分割字段:^A 日志格式:IP地址^A服务器时间^A请求参数 配置location,记录请求日志到本地磁盘 将数据按照给定的日志格式存储到本地磁盘 二 ...

  5. (lleetcode)Single Number

    Given an array of integers, every element appears twice except for one. Find that single one. Note:Y ...

  6. Android中取消GridView & ListView默认的点击背景色

    方法一: gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); listView.setSelector(new ColorDrawa ...

  7. iis 重新注册 .net 方法

    dhl:IIS注册ASP.NET 1.1.2.0.4.0_在win7下如果先安装vs2010 后安装iis7的话,必须注册iis才可以用.~~~!!鄙视微软   IIS中ASP.NET的版本号此时可选 ...

  8. Secretary Problem

    最好时机问题 n个值 前n/e都不选 然后取第一个大于前n/e个数中最大值的数 选中最大的概率为1/e

  9. Android布局

    android:gravity="center" android:orientation="vertical" android:orientation=&quo ...

  10. C++函数模板template

    一.  问题: 强类型语言要求我们为所有希望比较的类型都实现一个实例 int min(int a, int b) { return a < b ? a : b; } double min(dou ...