• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfscript Error Trapping

Participant ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

What is the proper syntax for trapping for errors in cfscript?
TOPICS
Advanced techniques

Views

438

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

<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....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

What sort of errors are you looking to trap?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

LATEST
> 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation