macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Error handling with CFFEED?

Subject: Error handling with CFFEED?
From: "lizard626"
Date: Mon, 20 Aug 2007 21:47:43 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
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



 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
 <html xmlns="http://www.w3.org/1999/xhtml";>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Untitled Document</title>
 </head>
 <body>

 <!--- Process the feed data if the user submitted the form --->
 <cfif isDefined("Form.Submit")>
   <cffeed source = "#theURL#"
 properties = "myProps"
 query = "myQuery">


   <!--- Display the feed output.
 Use conditional logic for to handle different feed formats. --->
   <cfoutput>
     <h2>#myProps.title#</h2>
   </cfoutput> <cfoutput query = "myQuery">
     <cfif myProps.version IS "atom_1.0">
       <h3><a href = "#linkhref#">#title#</a></h3>
       <p><b>Published:</b> #DateFormat(publisheddate)#</p>
       <cfelse>
       <h3><a href = "#rsslink#">#title#</a></h3>
       <p><b>Published:</b> #publisheddate#</p>
     </cfif>
     <!--- <p>#content#</p> --->
   </cfoutput>
 </cfif>

 <!--- The form for specifying the feed URL or file --->
 <cfform name = "SetFeed" preserveData = "yes"> Enter Feed URL:
 <cfinput type = "text" size = "60" name = "theURL">
 <br>
 <br>
 <cfinput type = "Submit" name = "submit" value = "Submit">
 </cfform>

 </body>
 </html>


<Prev in Thread] Current Thread [Next in Thread>