Esempio n. 1
0
 public ClaseException(int num)
 {
     try
     {
         ClaseException exception = new ClaseException();
     }
     catch (DivideByZeroException e)
     {
         throw new UnaExcepcion("Trato de dividir por 0", e);
     }
 }
Esempio n. 2
0
 public void mainException()
 {
     try
     {
         ClaseException exception = new ClaseException(0);
     }
     catch (UnaExcepcion e)
     {
         throw new MiException("Trato de dividir por 0", e);
     }
 }
        static void Main(string[] args)
        {
            try
            {
                ClaseException exception = new ClaseException(0);
                exception.mainException();
            }
            catch (UnaExcepcion e)
            {
                Console.WriteLine("Mensaje: {0}", e.Message);

                if (!(e.InnerException is null))
                {
                    Console.WriteLine("InnerException: {0}", e.InnerException.Message);
                }
            }

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                ClaseException exception = new ClaseException(0);
                exception.mainException();
            }
            catch (UnaExcepcion e)
            {
                string fecha = DateTime.Today.ToString();
                ArchivoTexto.Guardar(String.Format("{0}.txt", fecha), e.Message);

                if (!(e.InnerException is null))
                {
                    //ArchivoTexto.Guardar(DateTime.Now.ToString(), e.InnerException.Message);
                }
            }

            Console.ReadKey();
        }