Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CFTRY-CFCATCH not throwing errors on CFHTTP

161 views
Skip to first unread message

Ranger

unread,
Apr 29, 2006, 3:48:06 AM4/29/06
to
I am trying to catch any error that may occur in a CFHTTP statement
within a CFTRY-CFCATCH structure. Something like this:

<cftry>
<cfhttp method="Get" url="#job_url#" path="#expandPath("leads\.")#"
file="#reference#">

<cfcatch type="Any">
<cfset StatusCode = DateFormat(Now(),"dd-mmm-yy") & " [" &
#CFHTTP.statusCode# & "]">
</cfcatch>
</cftry>

However, neither the CFCATCH nor the CFHTTP.statusCode seems to work.
Errors occur, the page goes on processing, but no flags are being
thrown.

Any assistance with this would be greatly appreciated.
-Ranger

Ranger

unread,
Apr 29, 2006, 3:48:08 AM4/29/06
to

Ranger

unread,
Apr 29, 2006, 4:02:33 AM4/29/06
to
One more thing I forgot to mention---I am running this code on CF MX,
v. 6.1 for Windows. -Ranger

Peter Tilbrook

unread,
Apr 30, 2006, 1:56:16 AM4/30/06
to
Ranger wrote:
> One more thing I forgot to mention---I am running this code on CF MX,
> v. 6.1 for Windows. -Ranger
>
Reason for not upgrading to MX 7.01?

Ranger

unread,
Apr 30, 2006, 3:56:35 PM4/30/06
to
Well, I might, but my hosting company is at v6.1.

Would v.7.01 offer me the answer to my problem? I thought
cftry-cfcatch was introduced
in v4.5 and quite mature.

Bob Dively

unread,
May 1, 2006, 11:19:11 AM5/1/06
to
Ranger <ri...@onlineranger.com> wrote:
> I am trying to catch any error that may occur in a CFHTTP statement
> within a CFTRY-CFCATCH structure. Something like this:

> <cftry>
> <cfhttp method="Get" url="#job_url#" path="#expandPath("leads\.")#"
> file="#reference#">

> <cfcatch type="Any">
> <cfset StatusCode = DateFormat(Now(),"dd-mmm-yy") & " [" &
> #CFHTTP.statusCode# & "]">
> </cfcatch>
> </cftry>

> However, neither the CFCATCH nor the CFHTTP.statusCode seems to work.
> Errors occur, the page goes on processing, but no flags are being
> thrown.

Why would the page not go on processing? What do you mean by "no
flags are being thrown"?

--
Bob Dively | I used to be indecisive, but now I'm not sure...

stark

unread,
May 2, 2006, 10:40:38 AM5/2/06
to
If I'm not mistaken, there is no thrown error per se, CF will try to
connect to the url you specify and then fail silently if it can't. To
see if it failed (and end the page) you could look for the text
"Connection Failed" in cfhttp.fileContents.

Mike
www.fusebuilder.net

Adam Cameron

unread,
May 3, 2006, 7:54:36 PM5/3/06
to
> I am trying to catch any error that may occur in a CFHTTP statement
> within a CFTRY-CFCATCH structure. Something like this:
>
> <cftry>
> <cfhttp method="Get" url="#job_url#" path="#expandPath("leads\.")#"
> file="#reference#">

try/catch will not trap errors at the URL you are <CFHTTPing>, which is
what it seems you're wanting it to do.

There is *no* common ground / overlap between HTTP and CF processing.

<CFHTTP> makes an HTTP request. It captures the HTTP (note: NOT *CF*)
response. Even if the URL it requests causes a CF problem on the remote CF
server, the remote *HTTP* server (eg: Apache, IIS) will still respond with
a HTTP 200 status, which is "OK". The content of the response might have a
CF error in it, but from an HTTP standpoint, everything went fine.

If you're expecting <cfhttp> to analyse / react to CF errors on the remote
server, you might have to revise your logic.

I have never experienced <cfhttp> reporting HTTP statuses incorrectly.

--
Adam

Ranger

unread,
May 3, 2006, 10:45:06 PM5/3/06
to
Adam, Mike,

I don't think that CFHTTP is malfunctioning; it's most likely the code
I am using. But I thought the specific exceptions list, exceptions
like, "COMCOM.Allaire.ColdFusion.HTTPConnectionTimeout", would catch
the a failed connection error and allow me to taken action on it.
Please let me know if this or some other method is available. Thanks,
Rick

Adam Cameron

unread,
May 4, 2006, 4:28:02 AM5/4/06
to
> I don't think that CFHTTP is malfunctioning; it's most likely the code
> I am using. But I thought the specific exceptions list, exceptions
> like, "COMCOM.Allaire.ColdFusion.HTTPConnectionTimeout", would catch

It's not *throwing* that error. Perhaps internally (ie: within the code
for <cfhttp>) it could well be, but <cfhttp> wraps all that. A failed
connection is NOT an exception as far as CF / CFHTTP goes, so there's
nothing to catch.

> the a failed connection error and allow me to taken action on it.
> Please let me know if this or some other method is available. Thanks,

All the info you need is returned by <cfhttp>. You don't need to be
catching exceptions: it's done for you already. Just work with the status
codes returned by <cfhttp>.

--
Adam

0 new messages