I have a page where I make a remote request to an external API. I sometimes get request timeouts when making the request, so, my plan to set a timeout in the CFHTTP tag that is lower than my default requesttimeout setting and catch it. However, I can't get my CFTRY/CFCATCH to catch it. Here is my pseudo code:
private void function makeRequest(){
cfhttp(
url="https://api.somesite.com/",
method="POST",
timeout="1",
throwonerror="true",
result="LOCAL.ApiHttpResult"
) {
...
}
}
public void function tryRequest() {
try {
makeRequest();
}
catch(coldfusion.runtime.RequestTimeoutException e) {
abort;
}
}
I get the same result out of CFSCRIPT:
<cffunction access="public" returntype="void" name="tryRequest">
<cftry>
<cfscript>
makeRequest();
</cfscript>
<cfcatch type="coldfusion.runtime.RequestTimeoutException">
<cfabort />
</cfcatch>
</cffunction>
Is there something special about the CFHTTP timing out that makes this impossible to catch programmatically? Any ideas on how to do this?
Thanks....