honeybadger 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ## Honeybadger 1.11.0 (unreleased) ##
1
+ ## Honeybadger 1.11.1 ##
2
+
3
+ * Add option to log the exception locally when the API cannot be
4
+ reached.
5
+
6
+ *Justin Mazzi*
7
+
8
+ ## Honeybadger 1.11.0 ##
2
9
 
3
10
  * Filter params from query strings in rack env.
4
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -57,6 +57,7 @@ GEM
57
57
  rspec (~> 2.13)
58
58
  highline (1.6.20)
59
59
  json (1.8.1)
60
+ json (1.8.1-java)
60
61
  listen (1.3.1)
61
62
  rb-fsevent (>= 0.9.3)
62
63
  rb-inotify (>= 0.9)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/josh/code/honeybadger-ruby
3
3
  specs:
4
- honeybadger (1.11.0)
4
+ honeybadger (1.11.1)
5
5
  json
6
6
 
7
7
  GEM
data/honeybadger.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'honeybadger'
7
- s.version = '1.11.0'
8
- s.date = '2014-02-05'
7
+ s.version = '1.11.1'
8
+ s.date = '2014-02-21'
9
9
 
10
10
  s.summary = 'Error reports you can be happy about.'
11
11
  s.description = 'Make managing application errors a more pleasant experience.'
data/lib/honeybadger.rb CHANGED
@@ -16,7 +16,7 @@ require 'honeybadger/user_feedback'
16
16
  require 'honeybadger/railtie' if defined?(Rails::Railtie)
17
17
 
18
18
  module Honeybadger
19
- VERSION = '1.11.0'
19
+ VERSION = '1.11.1'
20
20
  LOG_PREFIX = "** [Honeybadger] "
21
21
 
22
22
  HEADERS = {
@@ -8,7 +8,7 @@ module Honeybadger
8
8
  :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass,
9
9
  :proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain, :framework,
10
10
  :user_information, :feedback, :rescue_rake_exceptions, :source_extract_radius,
11
- :send_request_session, :debug, :fingerprint, :hostname, :metrics].freeze
11
+ :send_request_session, :debug, :fingerprint, :hostname, :metrics, :log_exception_on_send_failure].freeze
12
12
 
13
13
  # The API key for your project, found on the project edit form.
14
14
  attr_accessor :api_key
@@ -103,6 +103,9 @@ module Honeybadger
103
103
  # +true+ to log extra debug info, +false+ to suppress
104
104
  attr_accessor :debug
105
105
 
106
+ # +true+ to log the original exception on send failure, +false+ to suppress
107
+ attr_accessor :log_exception_on_send_failure
108
+
106
109
  # A Proc object used to send notices asynchronously
107
110
  attr_writer :async
108
111
 
@@ -145,38 +148,40 @@ module Honeybadger
145
148
  'CGI::Session::CookieStore::TamperedWithCookie',
146
149
  'ActionController::UnknownAction',
147
150
  'AbstractController::ActionNotFound',
148
- 'Mongoid::Errors::DocumentNotFound']
151
+ 'Mongoid::Errors::DocumentNotFound',
152
+ 'Sinatra::NotFound']
149
153
 
150
154
  alias_method :secure?, :secure
151
155
  alias_method :use_system_ssl_cert_chain?, :use_system_ssl_cert_chain
152
156
 
153
157
  def initialize
154
- @api_key = ENV['HONEYBADGER_API_KEY']
155
- @secure = true
156
- @use_system_ssl_cert_chain = false
157
- @host = 'api.honeybadger.io'
158
- @http_open_timeout = 2
159
- @http_read_timeout = 5
160
- @params_filters = DEFAULT_PARAMS_FILTERS.dup
161
- @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
162
- @ignore_by_filters = []
163
- @ignore = IGNORE_DEFAULT.dup
164
- @ignore_user_agent = []
165
- @development_environments = %w(development test cucumber)
166
- @notifier_name = 'Honeybadger Notifier'
167
- @notifier_version = VERSION
168
- @notifier_url = 'https://github.com/honeybadger-io/honeybadger-ruby'
169
- @framework = 'Standalone'
170
- @user_information = 'Honeybadger Error {{error_id}}'
171
- @rescue_rake_exceptions = nil
172
- @source_extract_radius = 2
173
- @send_request_session = true
174
- @debug = false
175
- @hostname = Socket.gethostname
176
- @metrics = true
177
- @features = { 'notices' => true }
178
- @limit = nil
179
- @feedback = true
158
+ @api_key = ENV['HONEYBADGER_API_KEY']
159
+ @secure = true
160
+ @use_system_ssl_cert_chain = false
161
+ @host = 'api.honeybadger.io'
162
+ @http_open_timeout = 2
163
+ @http_read_timeout = 5
164
+ @params_filters = DEFAULT_PARAMS_FILTERS.dup
165
+ @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
166
+ @ignore_by_filters = []
167
+ @ignore = IGNORE_DEFAULT.dup
168
+ @ignore_user_agent = []
169
+ @development_environments = %w(development test cucumber)
170
+ @notifier_name = 'Honeybadger Notifier'
171
+ @notifier_version = VERSION
172
+ @notifier_url = 'https://github.com/honeybadger-io/honeybadger-ruby'
173
+ @framework = 'Standalone'
174
+ @user_information = 'Honeybadger Error {{error_id}}'
175
+ @rescue_rake_exceptions = nil
176
+ @source_extract_radius = 2
177
+ @send_request_session = true
178
+ @debug = false
179
+ @log_exception_on_send_failure = false
180
+ @hostname = Socket.gethostname
181
+ @metrics = true
182
+ @features = { 'notices' => true }
183
+ @limit = nil
184
+ @feedback = true
180
185
  end
181
186
 
182
187
  # Public: Takes a block and adds it to the list of backtrace filters. When
@@ -52,10 +52,12 @@ module Honeybadger
52
52
  JSON.parse(response.body).fetch('id')
53
53
  else
54
54
  log(:error, "Failure: #{response.class}", response, data)
55
+ log_original_exception(notice)
55
56
  nil
56
57
  end
57
58
  rescue => e
58
59
  log(:error, "[Honeybadger::Sender#send_to_honeybadger] Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
60
+ log_original_exception(notice)
59
61
  nil
60
62
  end
61
63
 
@@ -159,5 +161,17 @@ module Honeybadger
159
161
  log(:error, "[Honeybadger::Sender#setup_http_connection] Failure initializing the HTTP connection.\nError: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}")
160
162
  raise e
161
163
  end
164
+
165
+ def log_original_exception(notice)
166
+ if Honeybadger.configuration.log_exception_on_send_failure
167
+ if notice.respond_to?(:exception) && notice.respond_to?(:backtrace)
168
+ message = "#{notice.error_message}\n#{notice.backtrace}"
169
+ else
170
+ message = "#{notice}"
171
+ end
172
+
173
+ Honeybadger.write_verbose_log("Original Exception: #{message}", :error)
174
+ end
175
+ end
162
176
  end
163
177
  end
@@ -31,6 +31,7 @@ describe Honeybadger::Configuration do
31
31
  assert_config_default :async, nil
32
32
  assert_config_default :send_request_session, true
33
33
  assert_config_default :debug, false
34
+ assert_config_default :log_exception_on_send_failure, false
34
35
  assert_config_default :fingerprint, nil
35
36
  assert_config_default :hostname, Socket.gethostname
36
37
  assert_config_default :feedback, true
@@ -117,6 +118,7 @@ describe Honeybadger::Configuration do
117
118
  assert_config_overridable :hostname
118
119
  assert_config_overridable :metrics
119
120
  assert_config_overridable :feedback
121
+ assert_config_overridable :log_exception_on_send_failure
120
122
  end
121
123
 
122
124
  it "has an api key" do
@@ -132,7 +134,7 @@ describe Honeybadger::Configuration do
132
134
  :notifier_version, :params_filters, :project_root, :port, :protocol,
133
135
  :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure,
134
136
  :source_extract_radius, :async, :send_request_session, :debug,
135
- :fingerprint, :hostname, :metrics, :feedback].each do |option|
137
+ :fingerprint, :hostname, :metrics, :feedback, :log_exception_on_send_failure].each do |option|
136
138
  expect(hash[option]).to eq config[option]
137
139
  end
138
140
  end
@@ -108,6 +108,39 @@ describe Honeybadger::Sender do
108
108
  sender.send_to_honeybadger("stuff")
109
109
  end
110
110
 
111
+ it "should log the exception on any error" do
112
+ Honeybadger.configuration.log_exception_on_send_failure = true
113
+ notice = Honeybadger::Notice.new(:exception => Exception.new("bad things"))
114
+ sender = build_sender
115
+ sender.should_receive(:setup_http_connection).and_raise(RuntimeError)
116
+ sender.stub(:log)
117
+
118
+ Honeybadger.should_receive(:write_verbose_log).with(/Original Exception:.*bad things/, :error)
119
+ sender.send_to_honeybadger(notice)
120
+ end
121
+
122
+ it "should not log the exception on any error by default" do
123
+ notice = Honeybadger::Notice.new(:exception => Exception.new("bad things"))
124
+ sender = build_sender
125
+ sender.should_receive(:setup_http_connection).and_raise(RuntimeError)
126
+ sender.stub(:log)
127
+
128
+ Honeybadger.should_not_receive(:write_verbose_log).with(/Original Exception:.*bad things/, :error)
129
+ sender.send_to_honeybadger(notice)
130
+ end
131
+
132
+ it "should log the exception on a non-successful HTTP response" do
133
+ Honeybadger.configuration.log_exception_on_send_failure = true
134
+ stub_http(:response => Net::HTTPError)
135
+ notice = Honeybadger::Notice.new(:exception => Exception.new("bad things"))
136
+ sender = build_sender
137
+ sender.stub(:log)
138
+
139
+ Honeybadger.should_receive(:write_verbose_log).with(/Original Exception:.*bad things/, :error)
140
+ sender.send_to_honeybadger(notice)
141
+ end
142
+
143
+
111
144
  it "returns nil no matter what" do
112
145
  sender = build_sender
113
146
  sender.should_receive(:setup_http_connection).and_raise(LocalJumpError)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-05 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -360,7 +360,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
360
360
  version: '0'
361
361
  segments:
362
362
  - 0
363
- hash: 129438582068622733
363
+ hash: 2540152001783830478
364
364
  required_rubygems_version: !ruby/object:Gem::Requirement
365
365
  none: false
366
366
  requirements: