You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Erik Price <ep...@ptc.com> on 2003/03/12 22:04:58 UTC
[digester] handling exceptions with Digester
Hi,
I've read through the Digester docs but didn't see reference to this
topic. If I've missed it and someone can point out where I should be
looking, that'd be much appreciated.
I have an object on the Digester object stack and I want to invoke a
method on it that throws an exception. But since that method won't get
invoked until I invoke digester.parse(), the exception will be thrown at
that time, I suppose. But digester.parse() only throws IOException and
SAXException. Is there a way to propagate my exception up through the
parse() invocation so I can catch it and deal with it in my client code?
This is the method my digester is invoking:
public void setSortBy(String sortBy) throws ClassNotFoundException,
NoSuchFieldException,
IllegalAccessException {
java.lang.reflect.Field f = null;
try{
f = Class.forName("SortBy").getField(sortBy);
}
catch (ClassNotFoundException cnfe) {
throw new ClassNotFoundException();
}
catch (NoSuchFieldException nsfe) {
throw new NoSuchFieldException();
}
try {
this.setSortBy((SortBy)f.get(null));
}
catch (IllegalAccessException iae) {
throw new IllegalAccessException();
}
}
Thanks,
Erik