This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Catch connection errors and raise NotificationError for notify_entity

  • Loading branch information...
Jesse Stuart
Jesse Stuart committed Dec 12, 2012
1 parent 2914f91 commit dd6e1fd7033eaad9df2dea5701aac0e3e3464646
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/tentd/model/notification_subscription.rb
@@ -104,6 +104,9 @@ def self.notify_entity(entity, post_id, view='full')
res = client.post.create(post.as_json(:view => view), :url => path)
raise NotificationError.new("[#{res.to_hash[:url].to_s}] #{res.status}: #{res.body}") unless (200...300).include?(res.status)
res
+ rescue Faraday::Error::ConnectionFailed, Errno::ETIMEDOUT => e
+ url = res ? res.to_hash[:url].to_s : ""
+ raise NotificationError.new(:message => "[#{url}] #{e.message}", :backtrace => e.backtrace)
end
def notify_about(post_id, view='full')

0 comments on commit dd6e1fd

Please sign in to comment.