SAX2: Should SAXException extend IOException?

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

David Megginson wrote:
> Rajiv Mordani <Rajiv.Mordani at> writes:
> > 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. 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:
	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
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list