This content has been marked as final.
Show 4 replies
-
1. cfscript Error Trapping
ScottAtHelloMetro Jul 11, 2006 7:11 AM (in response to cutie369)<cftry>
*your code that may throw an error*
<cfcatch type="any"> *various error types can be specified here but 'any' catches all of them*
*Code that handles the error such as sending a message to the admin, redirecting the user, reloading the page, etc.*
</cfcatch>
</cftry>
I just realized your question is specific to cfscript. I'm not sure this is what you are looking for.... -
2. Re: cfscript Error Trapping
Dan Bracuk Jul 11, 2006 7:14 AM (in response to cutie369)What sort of errors are you looking to trap? -
3. Re: cfscript Error Trapping
cutie369 Jul 11, 2006 8:40 AM (in response to Dan Bracuk)I am looking to trap errors coming back from a SOAP call. The proper error message not getting processed properly by ColdFusion
<cfscript>
ws = createobject ( "webservice", " http://darin/webservicetest1/service1.asmx?WSDL");
try {
ret = ws.HelloWorld(true);
}
catch(any excp){
WriteOutput("error there: #excp# <br>");
}
header = getSOAPResponseHeader(ws, " http://tempuri.org/", "returnheader");
writeoutput ("header: " & #header# & "<br><br>");
writeoutput("returned value: " & #ret#);
</cfscript>
<cfoutput>
#htmlcodeformat(header)#
</cfoutput> -
4. Re: cfscript Error Trapping
Newsgroup_User Jul 11, 2006 10:07 AM (in response to Dan Bracuk)> catch(any excp){
> WriteOutput("error there: #excp# <br>");
> }
This itself will error as excp will be a struct, and you can't simply
output it like that. You probably want to output excp.message, or
something.
Other than that, your usage of try / catch is correct.
--
Adam