Hello Wolf,
thanks a lot for integrating my code into swixml. I appreciate it very
much and I'm honoured... :)
Nevertheless I have something I wish to change on the current
Parser.java regarding the error handling. You do a catch(Exception e) in
getSwing(Element, Object).
This is IMHO a bad idea, because everything is catched including quite
serious RuntimeExceptions. If there is some RuntimeException thrown by
the constructor or the getInstance() method, this exception is lost
except some output on stderr. If you e.g. want to connect to a server
during the creation of some Model, you are unable to indicate this with
a exception -- you have to cope with the error in the same place where
it happens instead handling the error on a central place.
Suggestion: First catch RuntimeException, throw it again to allow
further processing through objects expecting something to go wrong.
_Then_ catch the remaining exceptions and print the output:
try {
...
} catch(RuntimeException re) {
throw re;
} catch (Exception e) {
System.err.println(Parser.ATTR_INITCLASS + ":"
+ className + " not instantiated : "
+ e.getLocalizedMessage() );
}
This construct handles all the nasty things that may happen if you
provide the wrong class or the like. What do you think?