tracker issue : CF-3832126

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

CFHHTP result variable not available on error

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Mikaël Spruyt / Mikaël Spruyt (dreagan_design)

Created: 09/26/2014

Components: Net Protocols, HTTP

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / All users will encounter

Locale/System: English / Win All

Vote Count: 0

Problem Description:
When firing an HTTP-call inside a try-catch statement and it throws an error (on the target's end), the result variable, even though it was added as a parameter to the call, is not available.

Steps to Reproduce:
    <cfhttp url="#restUrl##arguments.method#/#arguments.params#" charset="utf-8" throwonerror="true" result="haha" />
    <cfcatch type="any">
        <cfdump var="#haha#" />
        <cfdump var="#cfcatch#" abort />

Actual Result:
"variable haha is not defined".

Expected Result:
the actual content of the result variable, with a possible error returned from the target, so that further actions could be based on the actual response.

Any Workarounds:
remove the onThrowError parameter and check for the statuscode returned from the HTTP-call. Based on that information, use the status code and the result variable as needed.

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

Watson Bug ID:	3832126

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

Coldfusion 10,0,13,287689


Windows 8 + IIS

java 1.7.0_15



This is not a bug as the variable is populated only when the code is successfully executed.
Comment by Vamseekrishna N.
10821 | November 11, 2014 04:23:55 AM GMT
Then explain to me why it does get populated when the onThrowError parameter si removed. The call still returns an error, the only difference is that you're expected to do the error-catching manually. A 500-server-error can contain al lot more information than what is presented in the error structure that gets populated when you do have the onThrowError parameter present in your CFHTTP-tag. In my case it is a server error that was issued by a service written by someone of our team, complete with a translation to show on the front-end and an error-code to pass to our error-tracker. I know this neither here nor there, but I want to note that this works as I described here (with populated respone and onThrowError present) on Railo platforms. Please take another look at this.
Comment by External U.
10822 | November 12, 2014 07:43:00 AM GMT
When you use ThrowOnError, you are telling the server that you want to handle the error yourself. The 'catch' struct would have 'type' which will tell you what type of error it was. You can also have multiple catch statement processing different type of errors. Check out
Comment by Rupesh K.
10823 | November 12, 2014 08:28:08 AM GMT