473,385 Members | 1,409 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,385 software developers and data experts.

Try-Catch error handling

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
May 30 '07 #1
5 1281
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.

"Blasting Cap" wrote:
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
May 30 '07 #2
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

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>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

May 30 '07 #3
Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
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

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>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

May 30 '07 #4
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
Blasting Cap wrote:
Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
>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

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>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

May 30 '07 #5
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
"Blasting Cap" <go****@christian.netwrote in message
news:e4**************@TK2MSFTNGP06.phx.gbl...
>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
Blasting Cap wrote:
>Bjorn:

Did you have any examples of this code online?

Thanks,

BC

Bjorn Sagbakken wrote:
>>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

"Blasting Cap" <go****@christian.netwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl.. .
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


May 31 '07 #6

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

Similar topics

39
by: Erlend Fuglum | last post by:
Hi everyone, I'm having some trouble sorting lists. I suspect this might have something to do with locale settings and/or character encoding/unicode. Consider the following example, text...
9
by: David Stockwell | last post by:
In referring to my copy of the python bible, it tells me I can't use all three items 'try' except and finally. I can use the t/f or t/e combinations though What combination can i use if i want...
26
by: djw | last post by:
Hi, Folks- I have a question regarding the "proper" use of try: finally:... Consider some code like this: d = Device.open() try: d.someMethodThatCanRaiseError(...) if SomeCondition: raise...
6
by: William Park | last post by:
(crossposted to comp.lang.python, because this may be of interest to them.) Python has try-block, within which you can raise exception. Once it's raised, execution breaks out of the try-block...
3
by: Steven Bethard | last post by:
So I have code that looks something like this: def f(xs): for x in xs: y = g(x) # can raise exception AnException for z in h(y): k(z) # can raise a variety of exceptions Now, if g(x) raises...
40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
4
by: wk6pack | last post by:
Hi, I was wondering why when I declare the dim variable outside the try statement, I could use the .dispose() function but when I declare it inside the try statement, I get Name 'varname' is not...
3
by: Sori Schwimmer | last post by:
Hi, I think that would be useful to have an improved version of the "try" statement, as follows: try(retrys=0,timeout=0): # things to try except: # what to do if failed
3
by: Bob Rock | last post by:
Hello, this is something I've been asking myself for sometime ... and now I'd like to clarify this point. When should the try block start in a method??? What I mean is, does having all the code...
2
by: Shi Mu | last post by:
very hard for me to understand the difference between try...except and try...finally
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.