Skip to main content
August 20, 2007
Question

Error handling with CFFEED?

  • August 20, 2007
  • 2 replies
  • 509 views
Hello, does anyone have a suggestion on handling errors from CFFEED reads?

I'm reading an ATOM RSS feed from another site, but if there is ever an issue with that remote site, it would prevent my page from loading.

If, for example, the RSS feed wasn't available, I would get an "Unable to read the source URL" error page.
What I would like to have happen would be the page to continue processing, and instead of displaying the <CFOUTPUT query = "myQuery">, instead display something like "There was a problem with the newsfeed".

Is there any way to ignore a "fatal error" from a CF tag, and just move on with processing the rest of the page?

The code I've used here is Adobe's example for the CFFEED tag. The RSS URL I'm testing with is:
http://feeds.emsresponder.com/emsresponderrss/top_ems_news

Thanks in advance!
-Ian in Los Angeles

    This topic has been closed for replies.

    2 replies

    August 21, 2007
    Use CFTRY and CFCATCH as suggested above. These tags can be used around pretty much any potentially problematic code.

    A good idea might be to put a CFMAIL tag in the CFCATCH which will notify you if something is wrong - although, this depends on how many people you'll have viewing the page, because you could end up getting a lot of emails - I'm sure there must be a better solution somewhere though, just an idea really.
    Inspiring
    August 20, 2007
    Yes you are in luck.
    <cftry>
    <!--- your code that might error --->
    <cfcatch type="any">
    <!--- your code to do on error --->
    </cfcatch>
    </cftry>
    August 21, 2007
    That worked perfectly! Thanks!

    I guess CFTRY and CFCATCH are just a couple of tags I never knew would make my life easier. :)

    Anyway, here's my updated code: