Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@www.apache.org Received: (qmail 61877 invoked from network); 1 Dec 2003 09:07:44 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 1 Dec 2003 09:07:44 -0000 Received: (qmail 99528 invoked by uid 500); 1 Dec 2003 09:07:03 -0000 Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 99395 invoked by uid 500); 1 Dec 2003 09:07:02 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 99382 invoked from network); 1 Dec 2003 09:07:01 -0000 Received: from unknown (HELO mailserver1.tse.dk) (195.41.123.120) by daedalus.apache.org with SMTP; 1 Dec 2003 09:07:01 -0000 Received: from [195.41.123.120] by mailserver1.pagedesigner.dk (NTMail 5.06.0016/NU0358.00.0f4c6384) with ESMTP id inkddaaa for struts-user@jakarta.apache.org; Mon, 1 Dec 2003 09:59:46 +0100 Received: FROM Henrik BY mailserver1.tse.dk ; Mon Dec 01 09:59:45 2003 +0100 Message-ID: <008e01c3b7ea$961f74a0$6900010a@tseintern.dk> From: "HG" To: "Struts Users Mailing List" References: Subject: Re: Struts Exception Handling Date: Mon, 1 Dec 2003 09:53:30 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Baljinder I use one common rule of thumb in regard to exception handling in Struts applications: "Never throw an exception in action classes, always catch exceptions in action classes" At lower layers (Business Delegate, EJB Facade, Data Access Object, etc) I COULD use exceptions to communicate errors to upper layers (Actions). I used the above scenario in several projects, but I also did projects where I never rethrow a catched exception, instead I return some sort of "errorcode". Anyone else can share their experience...I saw an article discussing this on theserverside.com for a while ago...quite good...maybe you should check it out. Best regards Henrik ----- Original Message ----- From: "Baljinder Singh" To: "Struts Users Mailing List" Sent: Monday, December 01, 2003 9:30 AM Subject: RE: Struts Exception Handling > Is anybody having any comments on exception handling strategies ?? I am > looking for solutions reagarding handling exceptions related to database. > > Thanks, > BS > > -----Original Message----- > From: Baljinder Singh > [mailto:baljinder.singh@interglobetechnologies.com] > Sent: Wednesday, November 26, 2003 11:44 AM > To: Struts Users Mailing List > Subject: RE: Struts Exception Handling > > > Phil & Mike, > > The approach that I am using right now is to make an ExceptionHandler and > configure it in struts-config.xml using something like following: > > > key="error.exception.SQL" > handler="com.exception.MyExceptionHandler" > path="error.jsp" /> > > > This way it would catch ALL database related exceptions and throw them. But > the problem goes deep into into handling a specific database exception, for > ex. duplicate key exception during insert operation or child dependency > during delete operation. Now different databases would throw different kind > of errors for these cases. My problem is how to catch these specific SQL > errors and show a user friendly message according to each of them. For ex, > when duplicate key exception is thrown, I want to show a message like > "Duplicate key cannot be inserted" or show a message like "Child record > exists for this key" for a child dependency case. How can I catch particular > error codes or message thrown by the database and show them and STILL KEEP > EVERYTHING GENERIC so that tommorrow if I change my database, I only need to > change the DAOs. > > Thanks & Rgds, > BS > > -----Original Message----- > From: Mainguy, Mike [mailto:MMainguy@kmart.com] > Sent: Wednesday, November 26, 2003 2:11 AM > To: 'Struts Users Mailing List' > Subject: RE: Struts Exception Handling > > > Welll, > The way I've done this before is to wrap all Exceptions in a Custom type > and throw it all the way back to struts. This seems to work well for > trivial business style apps, I'm not sure how it would hold up in something > with more complexity in the business layer. For example, My CRUD code would > catch SQL exceptions, check out what the real problem is, and, if it is a > genuine problem, throw a new FrameWorkException with the proper error > message (or message key) contained in it. > > I would also be curious on how other folks do such things however... > > > worse is better > > -----Original Message----- > From: Baljinder Singh [mailto:baljinder.singh@interglobetechnologies.com] > Sent: Tuesday, November 25, 2003 9:55 AM > To: Struts Users Mailing List > Subject: Struts Exception Handling > > > Hi All, > > I am looking for a robust exception handling approach in struts. Can > somebody help me in that. My framework consists of struts interacting with > session beans which then interact with DB through DAO. Now if during a CRUD > operation, for example there is a duplicate key exception thrown, how should > I handle it so that I can show the user exact message that duplicate key is > being inserted. Same for all kind of database messages and validations. > > Thanks & Regards, > BS > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > > ----------------------------------------- > This message and its contents (to include attachments) are the property of > Kmart Corporation (Kmart) and may contain confidential and proprietary > information. You are hereby notified that any disclosure, copying, or > distribution of this message, or the taking of any action based on > information contained herein is strictly prohibited. Unauthorized use of > information contained herein may subject you to civil and criminal > prosecution and penalties. If you are not the intended recipient, you should > delete this message immediately. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: struts-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org