Status/Resolution/Reason: To Fix//Investigate
Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)
Created: 10/23/2014
Components: Language
Versions: 11.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Trivial / Unknown
Locale/System: English / Platforms All
Vote Count: 5
In other languages like Java, I can catch an exception that was thrown from another library or subroutine and throw a new exception of my own that describes at a higher level what failed but still includes the original exception.
Java code:
try{
lib.doSomething();
} catch( Throwable e ){
throw(new RuntimeException( "Something bad happened in lib while we were trying to do X with it.", e ));
}
Note, the original exception object is passed into the constructor for the new error, so all those juicy details are not lost, but instead stored as the "cause" for my error. I am given the chance to generate a useful message that describes the context of the inner error without losing the original exception.
CFML doesn't allow me to do this and I am forced to cram the original message and stack trace into the detail of my new exception. <cfrethrow> doesn't help since it doesn't allow me to add my own message and stack trace.
Right now, the throw tag allows me to pass in an exception object, but it is mutually exclusive with the other parameters. I think the best solution might be to simply allow the exception to be passed into cfthrow alongside a new message, etc and it will become the nested "cause".
It would also be ideal if the "cause" would present itself the same way nested Java exceptions do so my code doesn't have to treat them differently. This would allow frameworks to easily display nested exceptions regardless of whether they came from Java or CF.
I have also put in this identical ticket for Railo and would appreciate a consistent implementation :)
https://issues.jboss.org/browse/RAILO-3239
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3842667
External Customer Info:
External Company:
External Customer Name: bradwood.com
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: