Raymond Lewallen

A few things .Net, a few things Sql

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456


Navigation

General

Subscriptions

Post Categories



Wednesday, December 22, 2004 - Posts

Constructors for Exception types won't take an inner exception parameter
I haven't looked at this in 2.0 yet, and hope somebody can answer this for me.

One of the biggest frustrations I have with 1.0/1.1 is that the FCL exception types do not have constructors that allow you to give it an exception object that sets the inner exception. Take the following example:
C#
public Int32 Foo(string value)
{
  try {
    return value.Length;
    } catch (NullReferenceException e) {
      throw new ArgumentNullException("value", "Cannot pass Nothing as a value.", e);
    }
}

VB
Public Function Foo(ByVal value As String) As Int32
  Try
    Return value.Length
    Catch e As NullReferenceException
      Throw New ArgumentNullException("value","Cannot pass Nothing as a value.", e)
  End Try
End Function

The above won't compile because most exception types don't have constructors that take exception objects as parameters to set their inner exception property. Somebody please tell me this is fixed in 2.0. Or I can just go look for it myself sometime during the upcoming holidays ;)

posted Wednesday, December 22, 2004 10:30 AM by rlewallen




Powered by Dot Net Junkies, by Telligent Systems