Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail silently when the http request fails #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/hipchat_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_url(object)
end

def send_message(data)
Rails.logger.info "Sending message to HipChat: #{data[:text]}"
Rails.logger.info "Sending message to HipChat room '#{data[:room]}': #{data[:text]}"
req = Net::HTTP::Post.new("/v1/rooms/message")
req.set_form_data({
:auth_token => data[:token],
Expand All @@ -121,7 +121,10 @@ def send_message(data)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
begin
http.start do |connection|
connection.request(req)
res = connection.request(req)
if res.code != '200'
Rails.logger.error "Failed to send message to HipChat: #{res.code} #{res.msg} (room: #{data[:room]})"
end
end
rescue Net::HTTPBadResponse => e
Rails.logger.error "Error hitting HipChat API: #{e}"
Expand Down