logo       

Re: [xml-dev] SAX/Java Proposed Changes: msg#00022

Subject: Re: [xml-dev] SAX/Java Proposed Changes
At 8:18 AM +0100 3/10/04, Jochen Wiedmann wrote:

Not quite like the paradigm of exception handling (catch the
exception in one place).

Throw is different from catch. If you throw a SAXException, then you're not handling it in that method, which is why you're throwing it; but you do make the decision of how to configure the object before throwing the exception. IN many cases you may not need to do any cleanup at all and can leave the object in an invalid state. You know whether or not you have to clean up, and what needs to be cleaned up because you've chosen to throw the exception. This is the qualitative difference from an exception the parser throws due to bad input.

But besides: Who tells you, that *I*
am throwing the Exception and not, for example, another ContentHandler
which I invoke?


If the other ContentHandler method is declared to throw a SAXException (the only checked exception it can throw) and you need to do cleanup, catch it and respond to it and then rethrow it. You still know where and when the exception can be thrown, which you do not know for a parser thrown exception.

By the way, although most of the time you can catch an exception in one place, that's not a rule written in stone. It does happen in more complicated situations that one catch block has to clean up in one method and then throw the same or a different exception up to another method, often in a different class. One of the benefits of the exception approach compared to traditional error handling is the easy reversal of the call chain, thus making complicated, multilayered responses possible.
--

  Elliotte Rusty Harold
  elharo@xxxxxxxxxxxxxxx
  Effective XML (Addison-Wesley, 2003)
  http://www.cafeconleche.org/books/effectivexml
  http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
List: sax-devel, sax-devel@xxxxxxxxxxxxxxxxxxxxx
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe