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

Error handling with CFFEED?

Guest
Aug 20, 2007 Aug 20, 2007
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

533
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
Engaged ,
Aug 20, 2007 Aug 20, 2007
Yes you are in luck.
<cftry>
<!--- your code that might error --->
<cfcatch type="any">
<!--- your code to do on error --->
</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
Guest
Aug 20, 2007 Aug 20, 2007
LATEST
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:
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
Guest
Aug 20, 2007 Aug 20, 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.
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