Try-Catch error handling

B

Blasting Cap

I would like for a page in my app (asp.net framework 2.0, VS 2005) to
both display a message to the user, as well as sending an email when an
error occurs.


I have code in the global.asax.vb codefile to generate an email when an
application error occurs, but is there a way to send an email to me when
this particular page has some sort of a SQL read error (or something
similar)?

I don't want to end the application, I would just like to throw a
message into a label on the page, and have the user continue with the
application, perhaps instructing them to click on a "return" button to
go back to the main menu.

Thanks,

BC
 
G

Guest

I'd be careful putting too much code in your error handling. I beleive the
server.scripttimeout is infinate after an error occured, so your thread could
hang for a long time waiting for the SMTP server.

Other than that, how about putting a try... catch ex as sqlException for
that particular page. Then you keep how you want to handle exceptions on
that page local to the code on that page instead of putting it in global.
 
B

Bjorn Sagbakken

I have just done that. I catch serious errors on each form, storing the
information about the error, source and errorcode in a session var. Then I
redirect the user to an error form that just displays the error message in a
nice way, based on the session var. But also, this error form form sends an
email back to me; containing the userID, the part of the application and the
errormessage itself. Very useful, and quite simple.

Bjorn
 
B

Blasting Cap

I guess what I am asking is there any way to supply the application with
the SMTP server name externally, like passing in a parameter name in a
config file that the app will pick up & be able to use across the
application?

BC
 
B

Bjorn Sagbakken

I am sure that can be done, even though I haven't done just that in VS 2005
yet.
To open a file and read the content shold be easy, something like declaring
a var as FileSystem, then open the deired file and read the content as text.

Bjorn
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top