exceptions 0.0.6 → 0.0.7
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 +4 -4
- data/lib/exceptions/backends/honeybadger.rb +10 -4
- data/lib/exceptions/backends/logger.rb +1 -0
- data/lib/exceptions/backends/multi.rb +10 -1
- data/lib/exceptions/backends/null.rb +3 -1
- data/lib/exceptions/result.rb +2 -2
- data/lib/exceptions/version.rb +1 -1
- data/spec/exceptions/backends/honeybadger_spec.rb +33 -0
- data/spec/exceptions/backends/multi_spec.rb +18 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f919423137f3aa99b716901546a5cb9fb0e50d8c
|
4
|
+
data.tar.gz: 2d5176e0c638e4b92cd7fb1fc6966edfa840df82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e7eaa404821953f1c3d59b3c6fdea2a4273e824a726ef1e5fd2d27e101ad686348aa464c0002ca26405a1e47f8e657624712e45a66faa750a8461597eadf90e
|
7
|
+
data.tar.gz: 2921f752da6ae19f505519c8115e0d35b170e5fc639159864f6150d64d4b431a14e40175f97a370829f7102c92571a2c94c24e32d34172251c0272427e4df9b9
|
@@ -5,8 +5,14 @@ module Exceptions
|
|
5
5
|
# Public: The Honeybadger backend is a Backend implementation that sends the
|
6
6
|
# exception to Honeybadger.
|
7
7
|
class Honeybadger < Backend
|
8
|
+
attr_reader :honeybadger
|
9
|
+
|
10
|
+
def initialize(honeybadger = ::Honeybadger)
|
11
|
+
@honeybadger = honeybadger
|
12
|
+
end
|
13
|
+
|
8
14
|
def notify(exception, options = {})
|
9
|
-
if id =
|
15
|
+
if id = honeybadger.notify_or_ignore(exception, options)
|
10
16
|
Result.new id
|
11
17
|
else
|
12
18
|
BadResult.new
|
@@ -14,15 +20,15 @@ module Exceptions
|
|
14
20
|
end
|
15
21
|
|
16
22
|
def context(ctx)
|
17
|
-
|
23
|
+
honeybadger.context ctx
|
18
24
|
end
|
19
25
|
|
20
26
|
def clear_context
|
21
|
-
|
27
|
+
honeybadger.clear!
|
22
28
|
end
|
23
29
|
|
24
30
|
def rack_exception(exception, env)
|
25
|
-
notify(exception, rack_env: env) unless
|
31
|
+
notify(exception, rack_env: env) unless honeybadger.
|
26
32
|
configuration.
|
27
33
|
ignore_user_agent.
|
28
34
|
flatten.
|
@@ -10,9 +10,18 @@ module Exceptions
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def notify(exception, options = {})
|
13
|
-
backends.
|
13
|
+
results = backends.map do |backend|
|
14
14
|
backend.notify exception, options
|
15
15
|
end
|
16
|
+
|
17
|
+
MultiResult.new results.map(&:id), results.map(&:url)
|
18
|
+
end
|
19
|
+
|
20
|
+
class MultiResult < ::Exceptions::Result
|
21
|
+
def initialize(ids, urls)
|
22
|
+
@id = ids.join(',')
|
23
|
+
@url = urls.join(',')
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
data/lib/exceptions/result.rb
CHANGED
@@ -9,14 +9,14 @@ module Exceptions
|
|
9
9
|
# This class is mostly a reference implementation but anything that conforms to the
|
10
10
|
# above interface is acceptable to return.
|
11
11
|
class Result
|
12
|
-
attr_reader :id
|
12
|
+
attr_reader :id, :url
|
13
13
|
|
14
14
|
def initialize(id = nil)
|
15
15
|
@id = id
|
16
16
|
end
|
17
17
|
|
18
18
|
def url
|
19
|
-
""
|
19
|
+
@url ||= ""
|
20
20
|
end
|
21
21
|
|
22
22
|
def ok?
|
data/lib/exceptions/version.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Exceptions::Backends::Honeybadger do
|
4
|
+
let(:honeybadger) { double(::Honeybadger) }
|
5
|
+
|
6
|
+
let(:backend) do
|
7
|
+
described_class.new honeybadger
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#notify' do
|
11
|
+
subject(:result) { backend.notify(boom) }
|
12
|
+
|
13
|
+
context 'when successful' do
|
14
|
+
before do
|
15
|
+
expect(honeybadger).to receive(:notify_or_ignore).and_return('1234')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns the result' do
|
19
|
+
expect(result.id).to eq '1234'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when errored' do
|
24
|
+
before do
|
25
|
+
expect(honeybadger).to receive(:notify_or_ignore).and_return(nil)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the result' do
|
29
|
+
expect(result.id).to eq nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Exceptions::Backends::Multi do
|
4
|
+
let(:backend) do
|
5
|
+
described_class.new \
|
6
|
+
double(Exceptions::Backend, notify: double(Exceptions::Result, id: 1, url: 'http://www.foo.bar')),
|
7
|
+
double(Exceptions::Backend, notify: double(Exceptions::Result, id: 2, url: 'http://www.bar.foo'))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#notify' do
|
11
|
+
describe 'result' do
|
12
|
+
subject(:result) { backend.notify(boom) }
|
13
|
+
|
14
|
+
specify { expect(result.id).to eq '1,2' }
|
15
|
+
specify { expect(result.url).to eq 'http://www.foo.bar,http://www.bar.foo' }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
@@ -94,7 +94,9 @@ files:
|
|
94
94
|
- lib/exceptions/version.rb
|
95
95
|
- lib/rack/exceptions.rb
|
96
96
|
- spec/exceptions/backends/honeybadger/integration_spec.rb
|
97
|
+
- spec/exceptions/backends/honeybadger_spec.rb
|
97
98
|
- spec/exceptions/backends/logger/integration_spec.rb
|
99
|
+
- spec/exceptions/backends/multi_spec.rb
|
98
100
|
- spec/rack/exceptions_spec.rb
|
99
101
|
- spec/spec_helper.rb
|
100
102
|
- spec/support/honeybadger.rb
|
@@ -124,7 +126,9 @@ specification_version: 4
|
|
124
126
|
summary: Exceptions is a Ruby gem for exception tracking.
|
125
127
|
test_files:
|
126
128
|
- spec/exceptions/backends/honeybadger/integration_spec.rb
|
129
|
+
- spec/exceptions/backends/honeybadger_spec.rb
|
127
130
|
- spec/exceptions/backends/logger/integration_spec.rb
|
131
|
+
- spec/exceptions/backends/multi_spec.rb
|
128
132
|
- spec/rack/exceptions_spec.rb
|
129
133
|
- spec/spec_helper.rb
|
130
134
|
- spec/support/honeybadger.rb
|