[OJB-developers] One more question
Brought to you by:
thma
From: <Joa...@tp...> - 2002-04-24 19:40:21
|
Hy, i forgot one question: it seems to me that OJB converts often between Exceptions (such as the NoSuchElementException that can happen with almost every problem). A mechanism like the cause-system introduced in J2SE 1.4 (and seen in a similar Way in the way JDBC handles Warnings/Errors) might be a good idea. IMHO the System from J2SE 1.4 would be ideal, but we obviously can't force everyone to use J2SE just because debugging get's easier this way ... The mechanism that 1.4 provides is basically that you can tell a newly created Exception (Throwable to be exact) what it's root cause was. This root cause (and its stack trace) is printed in addition to the normal stacktrace, when doing a printStackTrace(). This allows you to see all levels of a failure (high levels as in "couldn't load this object") to mid-level ("SqlException") to low-level ("Couldn't open ip-connection to server:port: access denied!"). I did a little Experiment and created a Bastard exception that used reflection to utilize the cause-system when it is available and doesn't break, when it is not. It can be compiled with 1.3 as well as with 1.4. It provides the benefit of a more detailed StackTrace, when beeing run in 1.4 (even if it was compiled in 1.3) and doesn't change any behaviour, when beeing run in 1.3. This is possible, 'cause I use Reflection to call the initCause()-Method. Normally I'd call this an ugly hack and would not allow such a thing in production code, but my reason to do it here is, that It provides enormous advantages while debugging and only slows down the process of throwing an exception (which only happens in Exceptional circumstances, where performance is not normally of any importance)). I've adapted PersistenceBrokerException locally to support this, the only change in API is a new Constructor that allows for both a Throwable and a String to be provided. I've tested it with 1.3 and 1.4 and both versions work (only 1.4 getting the benefit, 'though). If noone has any objections, I'd like to commit this (and adapt all other Exceptions to provide the same constructor). regards Joachim Sauer |