Which factory method in System.Linq.Expressions.Expression
should I call to create an expression tree -- more specifically, a CatchBlock
instance -- which represents the catch
in the following C# code:
try {
// ...
} catch {
// ...
}
All the overloads of the Catch method seem to require either an exception type -- the equivalent of this:
catch (Exception) {
// ...
}
and/or a ParameterExpression
which will be bound to the exception -- the equivalent of this:
catch (Exception ex) {
// ...
}
Passing null
into the first argument (and casting to Type
to avoid ambiguity):
// using static System.Linq.Expressions.Expression
Catch((Type)null, Constant(true));
causes an ArgumentNullException.
The MakeCatchBlock method has the same behavior