Error Handling

C

Chris

I have some code in my page error and application error event which handles
unhandled errors. This may seem a REALLY stupid question but if I have this
code why do I need to use try catch blocks. If there is an error I want my
page to stop executing and log/email the error. Regards, Chris.
 
M

Mark Fitzpatrick

Because the try/catch blocks can let you inform your user with a relevant
error message. There are lots of times when you want more control and trap
specific problems. For example, I'm reading nodes in an XML document and,
for some reason, one of the nodes contains data that is the wrong type for
that node. If the conversion is in a try/catch block, I can catch the error
and continue processing. I use this method a lot when reading rows from
things like excel spreadsheets so I can disregard the row that had an errant
column but continue processing the spreadsheet overall.
 
M

Mark Rae

If there is an error I want my page to stop executing and log/email the
error.

But that won't be much use to your unfortunate users - all they will see is
that your site has crashed...
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,264
Latest member
FletcherDa

Latest Threads

Top