tracker issue : CF-3842667

select a category, or use search below
(searches all categories and all time range)

Allow exceptions to be nested

| View in Tracker

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:
} 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  :)

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3842667

External Customer Info:
External Company:  
External Customer Name:
External Customer Email:  
External Test Config: My Hardware and Environment details:



Good call. Do it. ///////////////
Vote by External U.
10497 | October 23, 2014 02:54:47 PM GMT
Sounds good to me +1 .................................
Vote by External U.
10498 | October 27, 2014 05:37:23 AM GMT
+1 ............................
Vote by External U.
10499 | October 28, 2014 02:00:09 PM GMT
Would be nice.......................
Vote by External U.
10500 | October 28, 2014 07:22:28 PM GMT
+1 - This is a good idea ..........
Vote by External U.
10501 | November 26, 2014 03:54:58 AM GMT
I'd love to have this considered for CF12
Comment by External U.
10495 | July 09, 2015 02:09:55 PM GMT
Just talking about being able to nest exceptions this week. Any updates?
Comment by External U.
10496 | April 27, 2016 10:45:32 AM GMT