示例#1
0
        static StaticData()
        {
            // Exception created but is not thrown
            TestCreatedException = new SystemException("System Test Exception");

            // Traditional created and throw exception
            try
            {
                throw new RankException("Rank Test");
            }
            catch (RankException e)
            {
                TestThrowException = e;
            }

            // Exception containing inner exceptions
            try
            {
                try
                {
                    try
                    {
                        throw new TypeAccessException("Test Type Exception");
                    }
                    catch (TypeAccessException exp1)
                    {
                        throw new DivideByZeroException("Divide By Zero Test", exp1);
                    }
                }
                catch (DivideByZeroException exp2)
                {
                    throw new ArithmeticException("Inner Exception Test", exp2);
                }
            }
            catch (ArithmeticException exp3)
            {
                TestInnerException = exp3;
            }

            // Exception with a defined stack trace
            var callClass = new TestNamespace.ClassAlpha();

            try
            {
                callClass.ThrowException();
            }
            catch (TimeoutException exp)
            {
                TestCallStackException = exp;
            }
        }
        static StaticData()
        {
            // Exception created but is not thrown
            TestCreatedException = new SystemException("System Test Exception");

            // Traditional created and throw exception
            try
            {
                throw new RankException("Rank Test");
            }
            catch (RankException e)
            {
                TestThrowException = e;
            }

            // Exception containing inner exceptions
            try
            {
                try
                {
                    try
                    {
                        throw new TypeAccessException("Test Type Exception");
                    }
                    catch (TypeAccessException exp1)
                    {
                        throw new DivideByZeroException("Divide By Zero Test", exp1);
                    }
                }
                catch (DivideByZeroException exp2)
                {
                    throw new ArithmeticException("Inner Exception Test", exp2);
                }
            }
            catch (ArithmeticException exp3)
            {
                TestInnerException = exp3;
            }

            // Exception with a defined stack trace
            var callClass = new TestNamespace.ClassAlpha();
            try
            {
                callClass.ThrowException();
            }
            catch (TimeoutException exp)
            {
                TestCallStackException = exp;
            }
        }