[nem-en] Incorrect exception catching?

Snaury snaury at gmail.com
Fri Jun 30 09:46:50 CEST 2006


I was just blocked by some non-C# behaviour in Nemerle (0.9.3), if I
try to catch multiple exception, each case is wrapped in its own try
block, which makes the following code work correctly in C#, but
incorrectly in Nemerle:

// TARGET: test.exe
using System;
using System.Reflection;

public module Program
{
  public Main() : void
  {
    try {
      throw TargetInvocationException("generated exception",
Exception("this is my inner exception"));
    } catch {
      | e is TargetInvocationException => throw Exception("unable to
do it", e.InnerException);
      | e is Exception => throw Exception("unable to do it", e);
    }
  }
}

C#:

Unhandled Exception: System.Exception: unable to do it --->
System.Exception: this is my inner exception
   --- End of inner exception stack trace ---
   at Program.Main()

Nemerle:

Unhandled Exception: System.Exception: unable to do it --->
System.Exception: unable to do it ---> System.Exception: this is my
inner exception
   --- End of inner exception stack trace ---
   at Program.Main()
   --- End of inner exception stack trace ---
   at Program.Main()

I know that in this particular case I can do

  | e => match(e) {
    | _ is TargetInvocationException => ...
    | _ is Exception => ...
  }

to overcome it. But still I wonder if Nemerle's behaviour is designed
to be like this, or if it is a bug?



More information about the devel-en mailing list