Reflection will work. If you need to check specifically for
SqlException, it might be easier to do this:
// Assume the exception is in a variable named "exception".
SqlException sqlEx = exception as SqlException;
// If the variable is not null, then use it.
if (sqlEx != null)
{
// Work with sqlEx here.
}
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"pvdg42" <pv****@newsgroups.nospamwrote in message
news:up*************@TK2MSFTNGP06.phx.gbl...
>
"MikeJ" <ve***********@yahoo.comwrote in message
news:I3******************@newssvr27.news.prodigy.n et...
>Hi Im Building a error handler application
i dont know how to check the type of exception in my
messageformat() Method
also id like to know if a method is in the exception
Errors Collection in SqlException
how can i check the type of exception and if the
exception object has a Method
Tia
MJ
The System.Exception class should provide what you need.
http://msdn2.microsoft.com/en-us/lib...n_members.aspx
The getType() method and message property are good starting places.
Exception is the superclass for numerous exception types:
http://msdn2.microsoft.com/en-us/library/x4xzbdb9.aspx
If you catch Exception, you'll get a polymorphic reference to the actual
subtype.