lib/honeybadger/cli/notify.rb in honeybadger-3.0.2 vs lib/honeybadger/cli/notify.rb in honeybadger-3.1.0
- old
+ new
@@ -1,15 +1,17 @@
require 'digest'
require 'forwardable'
require 'honeybadger/cli/main'
+require 'honeybadger/cli/helpers'
require 'honeybadger/util/http'
require 'honeybadger/util/stats'
module Honeybadger
module CLI
class Notify
extend Forwardable
+ include Helpers::BackendCmd
def initialize(options, args, config)
@options = options
@args = args
@config = config
@@ -40,15 +42,14 @@
payload[:request][:action] = options['action'] if option?('action')
payload[:request][:url] = options['url'] if option?('url')
payload.delete(:request) if payload[:request].empty?
- http = Util::HTTP.new(config)
- result = http.post('/v1/notices', payload)
- if result.code == '201'
+ response = config.backend.notify(:notices, payload)
+ if response.success?
say("Error notification complete.", :green)
else
- say("Invalid response from server: #{result.code}", :red)
+ say(error_message(response), :red)
exit(1)
end
end
private