|
From: Colin S. <col...@ex...> - 2004-02-03 04:34:29
|
Oliver Hutchison wrote:
>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:
>
> try {
> this.getClass().getMethod("initCause", new Class[]
>{Throwable.class})
> .invoke(this, new Object[] {e});
> } catch(Exception ex) {
> // guess it's not 1.4+
> }
>
>
>Ollie
>
>
Coincidentally, we had a bit of a discussion about this w/regards to
NestedCheckedException, just a couple of days ago.
I should be able to find time tomorrow to to change
NestedCheckedException and NestedRuntimeException in this fashion...
|