[jdom-interest] NoSuch*Exceptions in JDOM

Thomas M. Sasala tsasala at hifusion.com
Fri Jun 16 04:42:09 PDT 2000


Dino Valente wrote:
> 
> At 04:57 PM 6/15/00 -0500, Brett McLaughlin wrote:
> >Simon Rade wrote:
> > >
> > > Hi!
> > >
> > > Element's methods getAttribute() and getChild() now throws
> > > NoSuchElementException and NoSuchAttributeException.
> > > Do you think this is better than returning null in such cases?
> > > Since it often happens that you don't know whether child or attribute
> > > exists and it is very awkward to handle those Exceptions.
> >
> >Yup. We went over this a bit - you don't want to ever have to really
> >check for null in code, it isn't that great of a practice.
> 
> I disagree. Doing a try/catch for each optional attribute or element is
> even worse.
> 
	I agree.  The exception (in this case) is a real pain.
we created a util that just returns null.....



More information about the jdom-interest mailing list