exception_handling 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de8ca845a02baac1f3d11d1c1e3ff419698ed239
4
- data.tar.gz: 57789ae890ab9c9cc2c8f1bce947ca7b58660082
3
+ metadata.gz: f7a5247d7f017803d5980c254bae1a598f8f6db3
4
+ data.tar.gz: 12edf7f3951cc443f5827c81f4f3e101b7b68c62
5
5
  SHA512:
6
- metadata.gz: 5450a2e7753d4e34927f25d0fe21929b5e1670eba9e88e8a2add7e6b8f6fc027343b6771e192875e657e7b7734c9bfd20d3551f123293c52ce5355974a1fa844
7
- data.tar.gz: dd96400045fec01c3ce1c38d2e8d9f2a800ecfd67713fe23fc3c9d1053dffe6956e2735dece5befe8e0c1dfde66a2e7814e3a80847b3d416868d4fb823f0cd14
6
+ metadata.gz: 93c6a4c4452b9523556b5e24623fff2879978cf022c371d45acb537ab7fd6570200d56b0bc95edd412aa1704f0c33ebdf8a256a44c65e3d415e8edffcbfc0098
7
+ data.tar.gz: d018fbb57661e0bcc1c064378640f750eabbfd0218e5b306f55f9b69bc0fbf239bf2f164542d97c2e5926ac3829f29f76cb491aadc695ba62f21544bf0d0aa33
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exception_handling (1.1.0)
4
+ exception_handling (1.2.0)
5
5
  actionmailer (~> 3.2)
6
6
  actionpack (~> 3.2)
7
7
  activesupport (~> 3.2)
@@ -45,14 +45,14 @@ GEM
45
45
  builder (3.0.4)
46
46
  coderay (1.1.0)
47
47
  erubis (2.7.0)
48
- eventmachine (1.0.8)
48
+ eventmachine (1.0.3)
49
49
  hike (1.2.3)
50
50
  hobo_support (2.0.1)
51
51
  rails (~> 3.2.0)
52
52
  i18n (0.6.11)
53
53
  invoca-utils (0.0.2)
54
54
  journey (1.0.4)
55
- json (1.8.3)
55
+ json (1.8.1)
56
56
  mail (2.5.4)
57
57
  mime-types (~> 1.16)
58
58
  treetop (~> 1.4.8)
@@ -67,12 +67,12 @@ GEM
67
67
  coderay (~> 1.1.0)
68
68
  method_source (~> 0.8.1)
69
69
  slop (~> 3.4)
70
- rack (1.4.7)
70
+ rack (1.4.5)
71
71
  rack-cache (1.2)
72
72
  rack (>= 0.4)
73
73
  rack-ssl (1.3.4)
74
74
  rack
75
- rack-test (0.6.3)
75
+ rack-test (0.6.2)
76
76
  rack (>= 1.0)
77
77
  rails (3.2.19)
78
78
  actionmailer (= 3.2.19)
@@ -101,7 +101,7 @@ GEM
101
101
  activesupport (>= 3.0.0)
102
102
  bourne (~> 1.3)
103
103
  slop (3.6.0)
104
- sprockets (2.2.3)
104
+ sprockets (2.2.2)
105
105
  hike (~> 1.2)
106
106
  multi_json (~> 1.0)
107
107
  rack (~> 1.0)
@@ -111,7 +111,7 @@ GEM
111
111
  treetop (1.4.15)
112
112
  polyglot
113
113
  polyglot (>= 0.3.1)
114
- tzinfo (0.3.45)
114
+ tzinfo (0.3.42)
115
115
 
116
116
  PLATFORMS
117
117
  ruby
@@ -171,6 +171,10 @@ EOF
171
171
  custom_description = ""
172
172
  write_exception_to_log(exception, custom_description, timestamp)
173
173
 
174
+ if honeybadger?
175
+ send_exception_to_honeybadger(exception, nil, timestamp)
176
+ end
177
+
174
178
  if should_send_email?
175
179
  controller = env['action_controller.instance']
176
180
  # controller may not exist in some cases (like most 404 errors)
@@ -202,6 +206,10 @@ EOF
202
206
 
203
207
  write_exception_to_log(ex, exception_context, timestamp)
204
208
 
209
+ if honeybadger?
210
+ send_exception_to_honeybadger(ex, exception_context, timestamp)
211
+ end
212
+
205
213
  if treat_as_local
206
214
  return
207
215
  end
@@ -243,6 +251,21 @@ EOF
243
251
  end
244
252
  end
245
253
 
254
+ #
255
+ # Log exception to honeybadger.io.
256
+ #
257
+ def send_exception_to_honeybadger(ex, exception_context, timestamp)
258
+ custom_message = "(Error:#{timestamp}) #{ex.class} #{exception_context} (#{ex.message}): " + clean_backtrace(ex).join(" ")
259
+ Honeybadger.notify(ex, context: { custom_message: custom_message })
260
+ end
261
+
262
+ #
263
+ # Check if Honeybadger defined.
264
+ #
265
+ def honeybadger?
266
+ Object.const_defined?("Honeybadger")
267
+ end
268
+
246
269
  #
247
270
  # Pull certain fields out of the controller and add to the data hash.
248
271
  #
@@ -1,3 +1,3 @@
1
1
  module ExceptionHandling
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -360,6 +360,36 @@ class ExceptionHandlingTest < ActiveSupport::TestCase
360
360
  end
361
361
  end
362
362
 
363
+ context "Honeybadger integration" do
364
+ context "with Honeybadger not defined" do
365
+ should "not invoke send_exception_to_honeybadger when log_error is executed" do
366
+ ExceptionHandling.expects(:send_exception_to_honeybadger).times(0)
367
+ ExceptionHandling.log_error(exception_1)
368
+ end
369
+
370
+ should "not invoke send_exception_to_honeybadger when ensure_safe is executed" do
371
+ ExceptionHandling.expects(:send_exception_to_honeybadger).times(0)
372
+ ExceptionHandling.ensure_safe { raise exception_1 }
373
+ end
374
+ end
375
+
376
+ context "with Honeybadger defined" do
377
+ setup do
378
+ stub(ExceptionHandling).honeybadger? { true }
379
+ end
380
+
381
+ should "invoke send_exception_to_honeybadger when log_error is executed" do
382
+ ExceptionHandling.expects(:send_exception_to_honeybadger).times(1)
383
+ ExceptionHandling.log_error(exception_1)
384
+ end
385
+
386
+ should "invoke send_exception_to_honeybadger when ensure_safe is executed" do
387
+ ExceptionHandling.expects(:send_exception_to_honeybadger).times(1)
388
+ ExceptionHandling.ensure_safe { raise exception_1 }
389
+ end
390
+ end
391
+ end
392
+
363
393
  class EventResponse
364
394
  def to_s
365
395
  "message from to_s!"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handling
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin Kelley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine