Fixed
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Brad Wood
Brad WoodPriority
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Created 22 July 2015 at 19:28
Updated 12 April 2025 at 08:46
Resolved 21 November 2016 at 22:26
The toPageException(Throwable) method in railo.runtime.op.Caster is losing the cause of my IOExceptions for the code in my Cache extension. For instance, when there is an error in the init() method for my cache, I am catching it and rethrowing wrapped in an IOException like so:
try { // Init cache here } catch (Throwable e) { throw( new IOException("Error initializing Cache.",e)); }
I would expect the error that's reported to the user and output in the logs to be something along these lines:
java.io.IOException: Error initializing Cache.
at ortus.extension.cache.couchbase.CouchbaseCache.init(Unknown Source)
...
Caused by: ACTUAL USEFUL CAUSE
...
However, what is actually logged and displayed looks like so:
Error initializing Cache.
at ortus.extension.cache.couchbase.CouchbaseCache.init(Unknown Source)
...
From that, it is impossible to tell what actually happened. It appears that many places in Railo's source (CachePut.java is one example), a checked exception is rethrown like so:
try { // Do something } catch (Exception e) { throw Caster.toPageException(e); }
I don't understand everything in the toPageException() method, but if the incoming Throwable is not of type PageException, PageExceptionBox, InvocationTargetException, ExceptionInInitializerError, or ExecutionException, a new NativeException is created which is stripping off the useful cause from my exception and the top-level exception is all that makes it to the user and into the logs. Interestingly enough, the following code is there but commented out:
//Throwable cause = t.getCause(); //if(cause!=null && cause!=t) return toPageException(cause);
Is there a reason the current behavior loses the cause, or is it just an oversight? The expectation is that when I throw an exception that is created with a cause, the cause will be in tact when my Exception is presented to the user/application error/handling.