I'm using a closed-source third-party library like this:
object val = SomeClass.ExtractValue( someObject );
Now somewhere further down the road, the third-party library tries to parse a DateTime value that has an unexpected format and throws a FormatException.
In this case, I would like to retrieve the string that it hasn't succeeded to parse and try to parse it myself. Something like this:
object val;
try
{
val = SomeClass.ExtractValue( someObject );
}
catch( FormatException e )
{
string failed = e.GetParseArgument( );
val = DateTime.Parse( failed + " 2010" );
}
Yes, simply appending the year is pretty pointless, but you get the idea. The third-party library doesn't support all formats I need, but I can't easily get the data from "someObject" either. (Yes, I could try to replicate what the library does using Reflector, but I'd like to avoid that.)
Is there any way to do this? Thanks.