简体   繁体   中英

Coldfusion: How to handle cfftp exceptions

I'm using Coldfusion version:8. I need to handle cfftp exceptions, which handles invalid credentials, connection timeout, no upload permissions, no delete permissions. what is the exact defined runtime exception for cfftp tag in Coldfusion.

Try using cftry tag:

<cftry>

FTP code here.

    <cfcatch type="exception type1">
        Add exception processing code here.
    </cfcatch>

    <cfcatch type="exception type2">
        Add exception processing code here.
    </cfcatch>

    <cfcatch type="Any">
        Add exception processing code appropriate for all other exceptions here.
    </cfcatch>

</cftry>

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Errors_13.html

Exception handling isn't going to help you if your request is served by the targeted webserver. Exceptions are only thrown if something unexpected occures while trying to send the request by ColdFusion, ie outgoing firewall blocks your request or any other kind of connection issue.

The only thing you need is the CFHTTP struct variable that is always generated after calling the tag. This struct contains all data related to the actual HTTP response. (Keeping the request within <cftry>/<cfcatch> is still suggested though.)

Here's an example requesting a non-existent website (404 Not Found) on Tomcat/Railo:

CFHTTP结果示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM