Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 80775 invoked from network); 25 Jun 2003 15:42:14 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 25 Jun 2003 15:42:14 -0000 Received: (qmail 19080 invoked by uid 97); 25 Jun 2003 15:44:37 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 19073 invoked from network); 25 Jun 2003 15:44:36 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 25 Jun 2003 15:44:36 -0000 Received: (qmail 80495 invoked by uid 500); 25 Jun 2003 15:42:11 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 80484 invoked from network); 25 Jun 2003 15:42:10 -0000 Received: from web20711.mail.yahoo.com (66.163.169.152) by daedalus.apache.org with SMTP; 25 Jun 2003 15:42:10 -0000 Message-ID: <20030625154213.58103.qmail@web20711.mail.yahoo.com> Received: from [32.97.110.142] by web20711.mail.yahoo.com via HTTP; Wed, 25 Jun 2003 08:42:13 PDT Date: Wed, 25 Jun 2003 08:42:13 -0700 (PDT) From: David Graham Reply-To: dgraham@apache.org Subject: Re: Checked vs Runtime exceptions To: Jakarta Commons Developers List In-Reply-To: <03bc01c33b2f$a3188260$0111010a@user> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --- Juozas Baliuka wrote: > Ok, > next example with checked exception in client code: > > void register(MyObject value)throws MyException{ > try{ > Connection connection = getConnection();// Doe's it throws > SQLException > too ? > try{ > updateOrInsert(connection,value); > log.info(" registred " + value.getId() ); > }finally{ > > connection.close(); // Doe's the caller better know how to handle > SQLException wrapped as MyException ? In many cases that a database operation fails the next layer just cares that it gets notified of the failure and logs it (you could also have subclasses of MyException that indicate more specific failure types). MyException is allowing other layers to be independent of the persistence implementation exceptions like SQLException. The commons-sandbox-mapper project provides this exact functionality. David > > } > }catch(SQLException e){ > throw new MyException(e); > }// LoggingException is a runtime exeption in this case > > } > > > ----- Original Message ----- > From: "David Graham" > To: "Jakarta Commons Developers List" > Sent: Wednesday, June 25, 2003 4:58 PM > Subject: Re: Checked vs Runtime exceptions > > > > --- Ryan Hoegg wrote: > > > This may be the "correct solution" in some of your eyes, but it is > far > > > too much overhead for most programmers who want to use logging. If > my > > > database server is down or the logging directory can not be found > when I > > > > > > want to log something, my application code is not the right place to > > > handle that.MyMethodUsesLogging has no business handling those > > > exceptional cases. I think a RuntimeException is most appropriate > here. > > > > > > > Logging was merely an example (probably a poor one). I don't want to > > handle exceptions from my logging package but I wouldn't want it to > throw > > RuntimeExceptions either (unless I've misused the API). > > > > David > > > > > Juozas Baliuka wrote: > > > > > > > I think this logging example was a good one: > > > > > > > > void MyMethodUsesLogging()throws MyException{ > > > > try{ > > > > > > > > log.info("started"); > > > > > > > > }catch(LoggingException e){ > > > > > > > > log.error(e); // ?????????????????? > > > > > > > > throw new MyExeption(e); > > > > } > > > > > > > > > > > >} > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > > > > > > > > __________________________________ > > Do you Yahoo!? > > SBC Yahoo! DSL - Now only $29.95 per month! > > http://sbc.yahoo.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.491 / Virus Database: 290 - Release Date: 2003.06.21 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org