Wrox Programmer Forums
|
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
 
Old August 17th, 2006, 08:19 PM
Registered User
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to handle error or exception if it occurs

How can i manage the exeception in thebeerhouse, should i manage them on the BLL or presentation layer. For example, assume that admin can be able to update the category but category name must e unique i.e when i tried to update the category name it show exception System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object
what i would like is to capture this and display user friendly message to user instead of the errorpage. How can i do it?
Thank you

 
Old August 17th, 2006, 11:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's the question of the ages and there's no single right answer. It depends on how you want to handle the error. If you want to deal with it in the UI layer that that's not a bad place to put the exception handler.

Of course, it's best to modify the code so that no routine actions of a user can trigger an excpetion. But you shouldn't be paranoid about testing for everything up front so you should also design in exception handling.

I always include logging with exception handlers because it can alert me to design weaknesses that need to be addressed.

Eric
 
Old August 22nd, 2006, 08:07 PM
Registered User
 
Join Date: Aug 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I understood your points however the error occurs in the DAL
conn.Open();
int ret = cmd.ExecuteNonQuery(); //Error here when i tried to updated exist value
return (ret == 1);

I tried to catch Exception(TargetInvocationException) in the BLL and display appropriate user friendly message, However it won't work instead redirect to default error page in Asp.net
Server Error in 'thebeerhouse' Application...

One more problem is that how can i log the error in the text file. in the WebCustomEvent , Macro only provide the way to recorddelete event using health monitoring however there is not method is use to log if unexpected exception occurs

Can you give me some advices about this.
 
Old August 27th, 2006, 06:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm guessing it's a different exception, and therefore you didn't really catch it. Why not catch any kind of exception, and then test to see what it was?

Health monitoring isn't a good way to log errors. Do some research on a custom trace listener. It's used for both debug and trace messages. The TextFileTraceListener is a good choice to log to a file. You also need to ensure that your ASPNET user account has write access to that file.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How can handle OutOfMemory Exception jazzydonald Pro Visual Basic 2005 2 October 5th, 2007 07:10 AM
How to handle OutOfMemory Exception FileFound Visual Studio 2005 4 July 3rd, 2007 07:23 AM
How to handle the JSP Exception in Java sheetm JSP Basics 0 December 5th, 2006 03:14 AM
error occurs while uploading file to http://localh madhusrp ASP.NET 1.0 and 1.1 Professional 2 March 15th, 2006 11:41 AM
How to know when an exception occurs? ecobo C# 2 December 30th, 2004 04:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.