This behavior makes difficult to troubleshoot errors, especially in
external libraries. Example code:

public class ExceptionReThrow{
    public void Test(){
        try
        {
            M1 ();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }

    public void M1()
    {
        M2();
    }

    private void M2()
    {
        try{
            M3();
        }catch{
            throw;
        }
    }

    private void M3()
    {
        throw new NotImplementedException();
    }}

For Microsoft .Net output will be:

System.NotImplementedException: The method or operation is not implemented.
at TestApp.ExceptionReThrow.M3() in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 38 at
TestApp.ExceptionReThrow.M2() in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 32 at
TestApp.ExceptionReThrow.M1() in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 24 at
TestApp.ExceptionReThrow.Test() in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:line 14

For mono (4.2.3) output will be:

System.NotImplementedException: The method or operation is not implemented.
at TestApp.ExceptionReThrow.M3 () [0x00001] in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:38 at
TestApp.ExceptionReThrow.M2 () [0x00003] in
D:\source\TestApp\TestApp\ExceptionReThrow.cs:30

As you can see, mono looses stack between first and second catch
statements. What is the explanation for this feature? Can I disable it?
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to