C#之抛异常
2021-05-30 04:18
标签:rgs mes pac layer demo OLE code cep dao层 C#之抛异常 标签:rgs mes pac layer demo OLE code cep dao层 原文地址:https://www.cnblogs.com/talentzemin/p/11064793.htmlusing System;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
try
{
BLLLayer();
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
Console.WriteLine("===================================");
Console.WriteLine(ex.ToString());
}
Console.ReadKey();
}
static void BLLLayer()
{
try
{
DAOLayer();
}
catch (Exception ex)
{
//throw; //可溯源到DAO
//throw ex; //可溯源终点就是这里
//throw new Exception("BLL层异常"); //可溯源终点就是这里,抛出新的异常,吞并原来的异常
//throw new Exception("BLL层异常", ex); //可溯源终点就是这里,抛出新的异常,带着原来的异常
}
}
static void DAOLayer()
{
try
{
throw new Exception("DAO层异常");
}
catch
{
throw;
}
}
}
}