rescue pubsubhubbub error if your pod is offline (resolves issue when posting public posts in dev mode with no internet connectivity)

This commit is contained in:
danielgrippi 2011-12-31 13:47:53 -05:00
parent 5bbfebdba9
commit 018d516b48

View file

@ -8,15 +8,16 @@ class Pubsubhubbub
def initialize(hub, options={}) def initialize(hub, options={})
@headers = H.merge(options[:head]) if options[:head] @headers = H.merge(options[:head]) if options[:head]
@hub = hub @hub = hub
end end
def publish(feed) def publish(feed)
begin begin
response = RestClient.post(@hub, :headers => @headers, 'hub.url' => feed, 'hub.mode' => 'publish') return RestClient.post(@hub, :headers => @headers, 'hub.url' => feed, 'hub.mode' => 'publish')
return response rescue RestClient::BadRequest=> e
rescue RestClient::BadRequest=> e Rails.logger.warn "Public URL for your users are incorrect. (This is ok if you are in development and localhost is your pod_url) #{e.inspect}"
Rails.logger.warn "Public URL for your users are incorrect. this is ok if you are in development and localhost is your pod_url#{e.inspect}" rescue SocketError
Rails.logger.warn "Pod not connected to the internet. Cannot post to pubsub hub!"
end end
end end
end end