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

abort a failed process inside a .cfm page

New Here ,
Feb 16, 2009 Feb 16, 2009
Hello everyone,
I have been bothered by this for a while.
I have a cfm page that is doing a process of extracting data and ftp to locationA. I have this running for about two years. Then there came the need to do the same process and ftp to locationB. I did not want to repeat the process, so I added ftp locationB at the end of the program, to use the same data file
The process runs well all the time when I only had LocationA. The problem is locationB ftp server sometimes would close and not to let me connect. this would stall the whole process (I gues it was a rollback feature in cold fusion?), including the steps of ftp to locationA, even though locationA's connection was fine and open.
Is there a way in Cold fusion pages to abandon a step that fails? In this case, I can put the code to ftp locationB in a template. If this template fail, go on to the the next line in the main page and not to quit the whole thing? I have seen this in other programming languages which have the "abort" function.

Thanks in advance,
449
Translate
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 ,
Feb 16, 2009 Feb 16, 2009
cftry/cfcatch.

Translate
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
New Here ,
Feb 16, 2009 Feb 16, 2009
Thank you for your suggestions.
I read the Help section for cftry and cfcatch. the example given is for a database query error. When I replace it with the type with "application", the cftry and cfcatch did not work. It throw me the "ugly" message and stopped.
Here is the code that I would like to abort:

<cfftp action = "putfile"
username = "anonymous"
password = "mypassword"
server = "clientserver"
localFile = "c:/#filename#.xml"
remoteFile = "/uploads/#filename#.xml"
>

How should I define the cfcatch type here for an ftp process?

Thanks!
Translate
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
New Here ,
Feb 16, 2009 Feb 16, 2009
I figured it out!
Here is the code:
<cftry>
<cfftp action = "putfile"
username = "anonymous"
password = "mypassword"
server = "clientserver"
localFile = "c:/#filename#.xml"
remoteFile = "/uploads/#filename#.xml"
>
<!--- <p>... other processing goes here --->
<!--- specify the type of error for which we search --->
<cfcatch type = "application">
<!--- the message to display --->
<h3>You've Thrown a Application <b>Error</b></h3>
<cfoutput>
<!--- and the diagnostic message from the ColdFusion server --->
<p>#cfcatch.message#</p>
<p>Caught an exception, type = #CFCATCH.TYPE# </p>

</cfoutput>
</cfcatch>
</cftry>

All I care is that the program does not stop because of the ftp error. I don't need the detail error message. Once I took out the lines in the example, it worked fine.
Translate
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
Advocate ,
Feb 16, 2009 Feb 16, 2009
LATEST
You can always catch "any" exception thrown.
<cftry>
<cfftp action = "putfile"
username = "anonymous"
password = "mypassword"
server = "clientserver"
localFile = "c:/#filename#.xml"
remoteFile = "/uploads/#filename#.xml"
>
<cfcatch type="any">
<!--- do your thing here! --->
<cfdump var="#cfcatch#" />
</cfcatch>
</cftry>
Translate
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