
链接异常是一系列处理异常的try-catch语句。要创建异常链,即链接异常−
设置第一个try-catch −
示例
static void Main(string[] args) {
try {
One();
} catch (Exception e) {
Console.WriteLine(e);
}
}现在在方法One()下尝试使用try-catch −
示例
static void One() {
try {
Two();
} catch (Exception e) {
throw new Exception("First exception!", e);
}
}方法Two()还会继续链式异常。
HTShop网上购物系统由恒天网络科技有限公司根据国际先进技术和国内商务特点自主版权开发的一款具有强大功能的B2C电子商务网上购物平台。HTShop以国际上通用流行的B/S(浏览器/服务器)模式进行设计,采用微软公司的ASP.NET(C#)技术构建而成。 2007-11-10 HTShop CS 通用标准版 v1.1.11.10 更新内容自由更换模版功能开放 修改了购买多款商品,会员中心订单只显示
示例
static void Two() {
try {
Three();
} catch (Exception e) {
throw new Exception("Second Exception!", e);
}
}现在是下一个方法。
示例
static void Three() {
try {
Last();
} catch (Exception e) {
throw new Exception("Third Exception!", e);
}
}The takes us to the last.
Example
static void Last() {
throw new Exception("Last exception!");
}在运行上述代码时,异常会被处理如下 −
System.Exception: First exception! ---< System.Exception: Middle Exception! ---< System.Exception: Last exception! at Demo.Two () [0x00000] in <199744cb72714131b4f5995ddd1a021f>:0 --- End of inner exception stack trace --- at Demo.Two () [0x00016] in <199744cb72714131b4f5995ddd1a021f>:0 at Demo.One () [0x00000] in <199744cb72714131b4f5995ddd1a021f>:0 --- End of inner exception stack trace --- at Demo.One () [0x00016] in <199744cb72714131b4f5995ddd1a021f>:0 at Demo.Main (System.String[] args) [0x00000] in <199744cb72714131b4f5995ddd1a021f>:0









