Graceful way to handle execution expired and bad URI errors??

#1
Hello,
I have a program that takes blog urls that our customers enter into their profiles. In some cases they enter bad feeds (IE html pages instead of atom or rss), and it throws these two errors:

execution expired and bad URI errors in the view.

I need to find a graceful way to handle both. Preferably, if I could find a way to throw an error message for the execution expired after a certain time period would be great.

Here's the method code:

[code
def feed_widget_details
@page_object = getPageObject
if @page_object.has_chatter_source?(0)
@blog_url = "#{WEB_SERVER}/controller/rss/blog/#{@page_object.id_unique}"
elsif @page_object.has_chatter_source?(1)
@blog_url = 'http://reverb.feedxi.com/Warm.xml?url=' + @page_object.blog_feed
else
@blog_url = @page_object.blog_feed
end
end
[/code]

and here' s the view code:

[code
cache({:controller => "rss", :action => "feed_widget_details", :id => @page_object.id}, {:expires => 15.minutes}) do

begin
blog_contents = Net::HTTP.get(URI.parse( @blog_url + '&=' + params[:k] ))
rescue
blog_contents = '<title type="text">No blog entries</title>'
blog_contents
end

-%>
<%=blog_contents-%>

<% end -%>
[/code]

I just added the begin rescue block in the view but this seems like it could be an act of desperation more than a good fix.

Help!
 
Top