473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Error Question

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
Apr 15 '07 #1
3 1233

"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.
Apr 15 '07 #2
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.


Apr 15 '07 #3
cool thank you
MJ
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:Oc**************@TK2MSFTNGP04.phx.gbl...
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. net...
>>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.



Apr 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
1
by: D A H | last post by:
I have gotten the same exception in multiple projects. I have solved the underlying problem. My question is if anyone knew of a setting that would cause this exception to be thrown. A...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
40
by: vfunc | last post by:
I get an undefined reference error for a definition that clearly looks like it is in a .h file. So what can be the cause of an undefined reference error, when this .h file containing the...
1
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
15
by: Dave | last post by:
I am getting the error above intermittantly with an ASP 3.0 page using an MS Access 2003 database. I have searched Google extensively and found the following possible causes for this error: A...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.