[Mono-dev] Confusion with throw; and throw e

Konrad Kruczyński konrad.kruczynski at gmail.com
Fri Apr 6 10:22:48 UTC 2012


Here's another example:

using System;
using System.Runtime.CompilerServices;

namespace ETest
{
        class MainClass
        {
                public static void Main(string[] args)
                {
                        try
                        {
                                Fun();
                        }
                        catch(Exception e)
                        {
                                Console.WriteLine(e.StackTrace);
                        }
                }
                
                public static void Fun()
                {
                        try
                        {
                                Fun2();
                        }
                        catch(Exception e)
                        {
                                throw;
                        }
                }
                
                [MethodImpl(MethodImplOptions.NoInlining)]
                public static void Fun2()
                {
                        throw new Exception("Test");
                }
        }
}

Stack trace is the same if throw is changed to throw e. Is this a known
bug? I've found a bug considering "throw;" not preserving the stack
trace, but this one is opposite - "throw e" does not reset it ;)

--
Regards,
 Konrad



More information about the Mono-devel-list mailing list