Re: Error Question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"pvdg42" <pvdg42@xxxxxxxxxxxxxxxxx> wrote in message
news:upI4S6wfHHA.596@xxxxxxxxxxxxxxxxxxxxxxx

"MikeJ" <vettes_n_jets@xxxxxxxxx> wrote in message
news:I3eUh.10549$Kd3.2140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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/library/system.exception_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.




.



Relevant Pages

  • Re: SqlException deserialization
    ... InitialCatalog are invalid so a login exception is thrown. ... The stacktrace before serialisation is: ... > without deserialization). ... >> soapformatter and then deserialize and the resulting SqlException has ...
    (microsoft.public.dotnet.framework.adonet)
  • Sqlexception serialization/deserialization
    ... I'm having a problem with a SqlException that I am serializing and ... is a sql exception with the following message: ... StackTrace property. ... soapformatter and then deserialize and the resulting SqlException has ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: wtf?
    ... > called by the ASP classic app, ... >> other than error translation. ... > exception that comes from the command's execute method doesn't seem to ... > the time we might be content saying "SqlException", in this case, we ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: a criticism of java
    ... > a)Integer.parseInt was one of the method that got up my nose. ... catch (final Exception exception) ... IOException and a NumberFormatException with it, ... SQLException, and just logging it. ...
    (comp.lang.java.programmer)
  • Re: What SqlExceptions can be thrown
    ... There is no case where a SqlException exception would be ... > If all you need to know is if the stored procedure you ran completed ... > have more information based on the specific errors that SQL server returns. ...
    (microsoft.public.dotnet.languages.csharp)