using 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;
            }
        }
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-06-15
  • 2022-02-10
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2021-09-05
  • 2021-11-18
  • 2021-08-20
  • 2021-12-03
  • 2021-12-17
  • 2022-12-23
相关资源
相似解决方案