ExceptionExtensions
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的更多相关文章
- 《Prism 5.0源码走读》UnityBootstrapper
UnityBootstrapper (abstract class)继承自Bootstrapper(abstract)类, 在Prism.UnityExtensions.Desktop project ...
- 《Prism 5.0源码走读》Bootstrapper
Prism框架需要在应用程序启动的时候进行一些初始化的工作,Bootstrapper就是来做这些的,是其切入点. Bootstrapper主要要做的事有:创建和配置module catalog,创建D ...
- 处理 InnerException 最佳方案?
如何获取 innerException 内部错误信息 String innerMessage = (ex.InnerException != null) ? ex.InnerException.Mes ...
- [伟哥开源项目基金会](https://github.com/AspNetCoreFoundation)
伟哥开源项目基金会 GitHub_base=> 伟哥开源项目基金会 该项目作者为伟哥,GitHub地址:https://github.com/amh1979: 该项目维护者为鸟窝,GitHub地 ...
- .NET中的异常处理机制(二)
本文我们继续通过另一个例子来讲解在C#中如何捕捉异常并进行处理. 首先,我们新建一个控制台应用和一个Class Library Project.如下图所示. 图1 ConsoleUI应用 图2 Exc ...
- 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 ...
随机推荐
- 文档生成工具 appledoc
参考文章 1.安装: $ git clone git://github.com/tomaz/appledoc.git $ cd appledoc $ sudo sh install-appledoc. ...
- websocket 403
- java 虚拟机--新生代与老年代GC
Heap: JVM只有一个为所有线程所共享的堆,所有的类实例和数组都是在堆中创建的. Method area: JVM只有一个为所有的线程所共享的方法区.它存储类结构,例如运行时常量池,成员和方法数据 ...
- MyBatis操作指南-搭建项目基础环境(基于XML)含log4j配置
- select2插件的使用
<select id="prd_tech_for_load" class="selectable" style="width:180px;&qu ...
- erlang rabbitmq-server安装
erlang rabbitmq-server安装 yum -y install xsltproc fop tk unixODBC unixODBC-devel make gcc gcc-c++ k ...
- 【转】ubuntu 重启命令,ubuntu 重启网卡方法
ubuntu 重启命令 重启命令:1.reboot2.shutdown -r now 立刻重启(root用户使用)3.shutdown -r 10 过10分钟自动重启(root用户使用)4.shutd ...
- nginx限制访问速度
转自:http://siwei.me/blog/posts/nginx-ip 参考:http://tengine.taobao.org/document_cn/http_limit_req_cn.ht ...
- java 静态函数锁对象说明
在内存加载.class文件后,会自动创建一个对象,用于保存class的信息,与我们程序员手工创建的对象不一样.
- 纯CSS实现帅气的SVG路径描边动画效果(转载)
本文转载自: 纯CSS实现帅气的SVG路径描边动画效果