Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.

Commit

Permalink
Catch connection errors and raise NotificationError for notify_entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Stuart committed Dec 12, 2012
1 parent 2914f91 commit dd6e1fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tentd/model/notification_subscription.rb
Expand Up @@ -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')
Expand Down

0 comments on commit dd6e1fd

Please sign in to comment.