 |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0  | This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

April 1st, 2009, 04:05 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 20
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Error/Exception handling
hi,
Can anybody please tell me how do we handle errors?
Suppose I dont want to show the default error page or any system generated message but want to show a custom message according to the exception I get.
How do we handle this? And is there anyway we can maintain log files so we would be able to open them while the application is in production.
I hope somebody please give some idea on this or any resource I can go through.
Thanks for the help!
|
|

April 1st, 2009, 05:50 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
How long can you hold out?
I am just finishing up a new Wrox Blox that deals extensively with these very topics.
It should be available on the site in a couple of weeks.
Here is a brief blurb that describes the content.
Unravel the mysteries of exception handling in ASP.NET! After a detailed introduction to structured exception handling and exception propagation in the .NET Framework, youâll delve into a variety of practical topics such as: when, where, and how to properly throw, catch, and handle exceptions in your code; how to avoid triggering the most common CLR exceptions; handling exceptions in ASP.NET data sources, data-bound controls, and rich ASP.NET server controls; and processing unhandled exceptions at both the Page and Application levels. Weâll also walk through the building of a complete, reusable, and fully configurable ASP.NET exception processing framework that extends far beyond ASP.NETâs built-in error handling capabilities. Youâll learn how to collect information about the state of the application when the exception occurred; how to leverage various ASP.NET state-handling mechanisms such as Application, Context, Session, ASP.NET Cache, cookies, and querystrings to store and pass error data; create a friendly, informative, and highly functional custom error UI; show friendly error messages to ânormalâ visitors while showing detailed error reports only to site managers based on authentication, authorization, or IP; provide a way for users to add their own information to error reports; log and report errors via email, the Windows Event Log, XML files, or a custom database; and more. Once complete, youâll be able to quickly and easily add this new functionality to any web site you create using a simple .dll. A complete sample application and C# source code for the exception processing framework is available as a companion download.
|
|
The Following User Says Thank You to Lee Dumond For This Useful Post:
|
|
|

April 1st, 2009, 06:22 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
|
|
Quote:
Originally Posted by Lee Dumond
How long can you hold out?
|
lee,
after that description - not long i reckon. sounds like a long overdue resource and one that i shall definately be grabbing when it's made available.
great stuff - especially as it's at framework level rather than 'instance' level. my issues have always been this 'apples and pears' (or is that oranges and bananas  ) approach to enterprise level error handling and recovery. never totally committed to a universal approach, so i'm already relishing this as both an 'intellectual' read (don't place TOO much substance on the intellectual part :) and a practical approach to resolving my little exception grollies...
can't wait!!
|
|

April 1st, 2009, 06:44 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 20
Thanks: 7
Thanked 0 Times in 0 Posts
|
|
Hello Lee,
Thanks very much for your response and the resource you will be providing.
I can hold out until your resource is made available.
But I have an interview in a couple of days so just wanted to find if there is any resouce that could help me with error handling / exception handling in the mean time.
Thanks again!
|
|

April 1st, 2009, 07:12 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
I guess you could Google or check out the MSDN, though be careful... you will run into a lot of bad information on the 'Net about this topic. Lord knows I did.
|
|

April 2nd, 2009, 12:48 PM
|
|
Friend of Wrox
|
|
Join Date: Feb 2009
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
|
|
Lee,
Thanks for putting this together. I too am very interested in seeing it when it's available.
I know you follow Jeff Atwood so you may already know about an article and code he posted, now long ago, on CodeProject for .NET error/exception handling. It is specific to winforms, but at the code level error trapping should have many similarities whether web or winform. It might be worth a look for you, Jyothi and any others interested in the topic.
Steve
|
|
The Following User Says Thank You to Steve S For This Useful Post:
|
|
|

April 2nd, 2009, 01:12 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Ah yes Steve, that is an oldie-but-goodie, back from when Jeff actually used to sling code for a living.
His advice about when to catch / not catch is pretty good, though I think he is being somewhat namby-pamby about not catching System.Exception ("when possible"). I would go further and say that I cannot ever recall a situation where I thought it was a good idea.
In fact, I understand that the 4.0 version of the CLR is going to make it harder to catch(Exception) by issuing a compiler warning, and possibly even requiring the use of a special keyword to do it.
Last edited by Lee Dumond; April 6th, 2009 at 11:00 AM..
|
|

April 8th, 2009, 01:28 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Table Of Contents
Hello all,
In the interest of whetting your appetites, I am posting the TOC of this upcoming Blox:
Quote:
Introduction
What is an Exception?
The Exception Class
Property Members
Method Members
Structured Exception Handling
Handling Exceptions
Try-Catch
Type Filtering
Finally
Exception Propagation: Part 1
Throwing Exceptions
Exception Handling Best Practices
Defensive Programming
Validating Input
Checking for Error Conditions
Choosing the Right Exception to Throw
Exceptions Should Be Exceptional
Donât Abuse Exceptions
Avoid Swallowing Exceptions
Donât Try to Handle Everything
Other Exception Handling Scenarios
Handling Exceptions in ASP.NET Data Sources
Handling Exceptions in ASP.NET Data-Bound Controls
Handling Exceptions in ASP.NET Rich Server Controls
Managing Unhandled Exceptions in ASP.NET
Exception Propagation: Part 2
The ASP.NET Default Exception Handler
Page.Error and HttpApplication.Error
Building a Custom ASP.NET Exception Handler
The âFourth Coffeeâ Sample Site
The LD.ExceptionHandling Class Library
Custom Configuration
Handling and Redirecting
Collecting Information
Storing and Retrieving
Logging and Notification
Creating a Custom Error UI
The Error Page
Pages for HTTP Errors
The Admin Pages
Adding the Custom Exception Handler to Your Own Site
Conclusion
|
|
|

April 8th, 2009, 07:38 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2007
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
|
|
lee - is whetting the same as scaring
nah, seriously, looks good, can't honestly wait...
nice one
[edit] i come from a c/c++ background but actually used (due to commercail 'demand') vb3-6 immediately after 'learning' the mfc framework. as a result, in vb i tended to always 'test' for errors, rather than using vb's very weak 'on error' primitive. in c#, altho' i do use try/catch/finally blocks, i do feel that i tend to revert back to those same 'tests' in the language and have always been looking for an error handling framework to take me beyond those limiting boundaries.
in a nutshell, if you can deliver this, you've addressed a longstanding ommission in my .net arsenal... yow
Last edited by jimibt; April 8th, 2009 at 07:47 PM..
|
|

April 8th, 2009, 08:19 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Quote:
Originally Posted by jimibt
in vb i tended to always 'test' for errors, rather than using vb's very weak 'on error' primitive. in c#, altho' i do use try/catch/finally blocks, i do feel that i tend to revert back to those same 'tests' in the language
|
In the Blox, I explain that in many cases, "testing" for conditions which might throw an exception, and coding around those conditions, is actually more efficient than handling the exception. For example:
Code:
public double Average
{
get
{
try
{
return (double) Total / Num;
}
catch (DivideByZeroException)
{
return 0.0;
}
}
}
Code:
public double Average
{
get
{
if (Num == 0)
{
return 0.0;
}
else
{
return (double) Total / Num;
}
}
}
These two get accessors accomplish the same thing.
If you expect, given the conditions under which this property is normally evaluated, that Num == 0 will be a rather common "non-exceptional" state of affairs, then #2 is better.
However, if conditions are such that Num is not normally expected to be zero (in other words, Num == 0 would be considered an "exceptional" case), then #1 is better.
Again, this is explained in more detail in the Blox, along with a presentation of other common scenarios in which programmatic error checking can be the superior option.
Last edited by Lee Dumond; April 8th, 2009 at 11:08 PM..
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Exception Handling |
NewTitle2007 |
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 |
6 |
August 8th, 2007 04:03 AM |
| exception handling |
jay schumacher |
VB.NET 2002/2003 Basics |
1 |
April 14th, 2006 08:40 AM |
| Exception handling |
aldwinenriquez |
General .NET |
0 |
August 17th, 2005 06:13 PM |
|
 |