how to get cfhttp.filecontent when throwonerror=tr

2019-07-13 12:02发布

问题:

I make a REST service call using cfhttp with the throwonerror attribute set to true. When I use a try/catch statement to capture the error, I can't seem to find a way to output what error the REST service call tried to return, which would reside in the cfhttp.filecontent variable.

I also tried putting the result in a variable. Coldfusion keeps telling me that cfhttp and that variable dont exist. It seems like the call and its result get thrown out the door when an exception is raised.

I've read some advice on setting throwonerror=false and capturing the statuscodes myself, but that seems like silly work. Anyody have any thoughts on this?

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

UPDATE: I've submited a bug report to Adobe, as Adamn suggested: https://bugbase.adobe.com/index.cfm?event=newBug. I can confirm it works in Railo, but doesn't work on CF10. Adam could also confirm it doesn't work on CF11.