tracker issue : CF-4079303

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

Allow to set the exception cause when using cfthrow/throw

| View in Tracker

Status/Resolution/Reason: Needs Review//

Reporter/Name(from Bugbase): Alexandre Potvin Latreille / Alexandre Potvin Latreille (Alexandre Potvin Latreille)

Created: 10/26/2015

Components: Core Runtime

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: ALL / Win 2008 Server R2

Vote Count: 1

Problem Description: 

throw/cfthrow doesn't support the ability to specify an exception cause. Being able to specify which low-level exception caused the high-level exception is very useful in order to avoid swallowing important error details when throwing a custom exception in response to another exception.

Steps to Reproduce: -

Actual Result: - 

Expected Result:

We should be able to pass a "cause" argument to throw/cfthrow which would accept a java.lang.Throwable.

Any Workarounds:

We can directly instanciate a coldfusion.runtime.CustomException and call the initCause method.

<cftry>

	<cfthrow type="LowLevel" message="Low-level exception">
	
	<cfcatch type="any">
		
		<cfset highLevelEx = createObject('java', 'coldfusion.runtime.CustomException').init('HighLevel', 'message', 'detail', 'errorCode', 'extendedInfo')>
		
		<cfset highLevelEx.initCause(cfcatch)>
		
		<cfthrow object="#highLevelEx#">
		
	</cfcatch>
</cftry>

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

Watson Bug ID:	4079303

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

Attachments:

Comments:

+1 Vote must be between 25 and 4000 characters
Vote by External U.
5451 | October 26, 2015 10:38:25 AM GMT
When will this get reviewed?
Comment by External U.
5450 | June 07, 2016 03:28:39 PM GMT
Any update on this?
Comment by Alexandre P.
32084 | January 21, 2020 02:52:06 PM GMT