|
From: Oliver H. <Oli...@ou...> - 2004-02-02 23:10:48
|
I'm currently writing a simple little query system which will some times
execute queries using the JdbcTemplate but also some times need to do
direct execution using JDBC.
It the part of this code that is responsible for catching exceptions and
giving the user appropriate error messages I have had to write two sets
of code to find the root cause of exceptions as the
NestedRuntimeException in Spring has it's getRootCause method and most
of the other exception I encounter use getCause.
I think it would be great if Spring also supported the Java 1.4 style
getCause method. Why not just override the getCause method with a call
to getRootCause? Or if you didn't want to do that this could be added
quite easily using reflection. Something like this in the constructor
should do the trick:
=20
try {
this.getClass().getMethod("initCause", new Class[]
{Throwable.class})
.invoke(this, new Object[] {e});
} catch(Exception ex) {
// guess it's not 1.4+ =20
}
Ollie
|