java - Exclusion from general-purpose exception chaining facility in 'remote' exceptions -
consider of 'remote' exceptions:
javax.jms.jmsexception
or java.rmi.remoteexception
both exclude common pattern of exception chaining having detail or linked exception properties.
when print stack trace containing 1 of exceptions you'll trimmed stack trace. full stack trace need additional dancing tambourines.
what reason remote exceptions designed way?
edit:
i'm browsing sources of java 1.6.0_26. on 2 arguments constructor public remoteexception(string s, throwable cause)
of java.rmi.remoteexception
. can see next code initcause(null); // disallow subsequent initcause
. seems intentional decision in java se 6 that.
but acording common practice initcause()
has it's grand purpose construct exceptions chain!
don't remember source i'm confident best practice of creating custom exception:
1. expose of constructors of super class
2. don't brake exceptions chain (call throwable.initcause()
in other words). achived calling super constructor.
thanks.
guess it's time update java :)
as of release 1.4, exception has been retrofitted conform general purpose exception-chaining mechanism. "wrapped remote exception" may provided @ construction time , accessed via public detail field known cause, , may accessed via throwable.getcause() method, aforementioned "legacy field."
http://docs.oracle.com/javase/1.5.0/docs/api/java/rmi/remoteexception.html
edit:
and answer question well: bad design decision, got corrected in 1.4
Comments
Post a Comment