SAX2: Should SAXException extend IOException?

David Brownell david-b at pacbell.net
Sun Jan 2 22:33:21 GMT 2000


David Megginson wrote:
> 
> Rajiv Mordani <Rajiv.Mordani at eng.sun.com> writes:
> 
> > java.util.zip.ZipException deriving from IOException is
> > appropriate. It is related to i/o so it makes sense to have that.

Also, the only place it's documented to be thrown is in a constructor
which also throws IOException.  I expect the documentation is missing
a fair number of uses though -- which often happens when an exception
inherits from another one.


> I'd be interested in a clear statement of the criteria for this
> distinction

I doubt you'll get such a clear statement.  Organizational politics
have come in, as well as sloppiness on the part of some developers.
That's not just at Sun; many organizations get that way for any
particular category of design decision you can identify.

I'll just say that questions get asked if an exception has strange
inheritance, which can permit it to masquerade as something it isn't,
and defining new categories of RuntimeException is really perceived
as undesirable.  Increasingly, those questions need good answers if
such exceptions are expected to become parts of public APIs.


>	 -- you get a ZipException, presumably, because of an error
> in the format of the zip file you're reading from;

Curious example.  java.util.zip.DataFormatException is what I'd
expect to get when faced with bad ZIP data.  (Recalling some of
the chaos involved in seeing JDK 1.1 get ZIP/JAR support, it's
no surprise that its exception architecture seems pretty odd.)

That's not an IOException.


>	 you get a
> SAXException because of an error in the format of the XML file you're
> reading from.

Looking at the JDK 1.2 javadocs, I also see these data format style
exceptions, which don't derive from IOException:

	java.security.certificate.CertificateEncodingException
	java.security.certificate.CertificateParsingException
	java.text.ParseException
	java.lang.NumberFormatException
	java.awt.image.RasterFormatException
	org.omg.CORBA. ... several ...

As with XML format errors, higher layers won't usually see those;
they get morphed by intermediate layers into diagnostics that are
more task-relevant.  (A few of those are RuntimeExceptions though.)

- Dave

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list