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 ...
随机推荐
- ios-获取通讯录 姓名和电话
#import "ViewController.h" #import <ContactsUI/ContactsUI.h> @interface ViewControll ...
- 11高级网站构建:div和span
用<div>元素把属于一个逻辑部分的元素包围起来.可以用id属性为<div>提供一个唯一的标签. <div>的作用:1.更深一步展示页面的基本逻辑结构(相当于一个逻 ...
- 修改ArcGIS Server Account / 站点管理员的 账号、密码
安装ArcGIS Server(10.1之后版本)时会先后创建两个账户:ArcGIS Server Account和站点管理账户 ArcGIS Server Account 是操作系统账户,Serve ...
- Android BLE 蓝牙低功耗教程,中央BluetoothGatt和周边BluetoothGattServer的实现
http://blog.csdn.net/wave_1102/article/details/39271693 分类: Android(105) 作者同类文章X Android4.3 规范了BLE的A ...
- 并发两个Thread的怪事——已解决
截图是马士兵视频的代码.我这样试了下,的确可行. 但是一般来说,主线程就是用来启动子线程的,所以我用了下图的形式,运行了3次.结果运行结果一直在变化,并且都没有正确的显示内容.这个截图里面编号11的线 ...
- zepto源码--核心方法8(管理包装集)--学习笔记
继续包装集过滤的相关函数的介绍,今天介绍与父元素相关的函数,parent, parents, closest, offsetParent parent 获取对象集合中每个元素的直接父元素. 与上篇文章 ...
- syslog-ng日志系统
一.基础syslog-ng作为syslog的替代工具,可以完全替代syslog的服务,并且通过定义规则,实现更好的过滤功能.系统自带版本(我的是红旗,不同系统用不同的方式查询): 引用 # rpm - ...
- Xcode命令行生成Bitcode静态库
近两三年一直在做静态库开发 1.在Xcode工程中创建静态库的Target,最初是手动Build出真机的.a文件,模拟器的.a文件,然后再用命令行合并 2.后来一些特殊的开发者,要求加入特殊的功能,或 ...
- [QGLViewer]First Demo
Dependencies: QGLViewer2.6.3 Win7 64bit VS2010 直接使用QGLViewer文件夹下的Pro文件在VS2010中可以编译成64位的Dll. 用外面的libQ ...
- jquery例子
jquery <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...