Exception Handling

G

Guest

Hi,
Question regarding exception handling in a distributed application - I have
a web service facade which expose methods to an asp.net client.
I'm thinking of handling application exceptions in the application_error in
the service global.asax.
Does the application_error occurs in the same thread as the current request
or does it occur in a main thread of the application?

Thanks

Yoav
 
V

Vadivel Kumar

It happens for entire Application. You can check this in Session_error
event, which will tell you the current context.

Moreover, I would like to suggest you to handle all the errors in the
methods and send your own exception class with formated exception
messages. Since it is a webservice you need to give back an IEnumerable
object which could sent as an xml data.

Let us know if you face any problems.

-
Vadivel Kumar
http://vadivelk.net
 
G

Guest

thanks for replying.
Do you mean that the thread which the application_error occurs in is the
same for the entire application?
I'm asking because it can be a problem if it happens in the same thread for
all the requests. it can cause a bottle neck.
As for formatting the message - I can format it in this event as well as in
the web methods, no?

thanks
 
V

Vadivel Kumar

I guess, you dont need to care about Application_error method, you have
just do this in session_error and implement the error handling in for
the current context. Perhaps, for all the sessions this method will get
fired and you put this message up.

As far as formatting goes, you should have a custom exception class and
in all the methods you throw the exception thru this. This class can
have all the implementation related to formating the message, stack
trace etc., based on your needs. You keep this object in a state object
which can hold the currently executed error (like win api's
GetLastError() ). In the session_error method call this method and put
the message in the screen after doing UI level formatting

Let me know if you have any issue.

-
Vadivel Kumar
http://vadivelk.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top