hbw 0.1.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 +7 -0
- data/.gitignore +50 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +41 -0
- data/LICENSE +21 -0
- data/README.md +142 -0
- data/Rakefile +2 -0
- data/bin/console +10 -0
- data/bin/rspec +2 -0
- data/bin/setup +8 -0
- data/hbw.gemspec +37 -0
- data/lib/hbw/version.rb +3 -0
- data/lib/hbw.rb +182 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 820fbb36d5486bbf4f7a81e62a508992b8197513f275d257de49d636d0a4b090
|
4
|
+
data.tar.gz: 72c8bbccc47e3ab5272a5cf75843cc3db8b93aaef98bf47fadcf6286a7c5bac1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ae608412930ed3a524536c60116c61f87ae21393a826eb08b2f940efb5325b16c94938bf74436ed094f07de9a865a5b21178e28ae63af1845263b2d73981f3b
|
7
|
+
data.tar.gz: 0a25eece2f08aa781c2b2ef9bbffb374cb3b2e893ff82b71939602e9d7e00685b95d9e3d3ccb1c6ac601a02296727f955a827b7d2adc42b8ec79ceba18290789
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hbw (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
method_source (0.9.0)
|
12
|
+
pry (0.11.3)
|
13
|
+
coderay (~> 1.1.0)
|
14
|
+
method_source (~> 0.9.0)
|
15
|
+
rake (10.5.0)
|
16
|
+
rspec (3.7.0)
|
17
|
+
rspec-core (~> 3.7.0)
|
18
|
+
rspec-expectations (~> 3.7.0)
|
19
|
+
rspec-mocks (~> 3.7.0)
|
20
|
+
rspec-core (3.7.1)
|
21
|
+
rspec-support (~> 3.7.0)
|
22
|
+
rspec-expectations (3.7.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.7.0)
|
25
|
+
rspec-mocks (3.7.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.7.0)
|
28
|
+
rspec-support (3.7.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.16)
|
35
|
+
hbw!
|
36
|
+
pry
|
37
|
+
rake (~> 10.0)
|
38
|
+
rspec (~> 3.7.0)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Nao Minami
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# HBW
|
2
|
+
|
3
|
+
Simple wrapper of [Honeybadger](https://github.com/honeybadger-io/honeybadger-ruby).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'hbw'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install hbw
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
By using `HBW.notify`, you can report error to honeybadger.io in production environment and raise error in development environment.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
HBW.notify("PaymentConfiguration", error_message, context: { company_id: self.id })
|
27
|
+
```
|
28
|
+
|
29
|
+
### Arguments
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# A. Exception only
|
33
|
+
HBW.notify(ex)
|
34
|
+
|
35
|
+
## equivalent code using `Honeybadger`
|
36
|
+
#
|
37
|
+
# if defined?(Honeybadger)
|
38
|
+
# Honeybadger.notify(ex)
|
39
|
+
# else
|
40
|
+
# raise ex
|
41
|
+
# end
|
42
|
+
|
43
|
+
# B. `error_class` and `error_message`
|
44
|
+
HBW.notify("PaymentConfiguration", "Empty payment period found in PaymentConfiguration#create_continuous_payments")
|
45
|
+
|
46
|
+
## equivalent code using `Honeybadger`
|
47
|
+
#
|
48
|
+
# if defined?(Honeybadger)
|
49
|
+
# Honeybadger.notify(
|
50
|
+
# error_class: "PaymentConfiguration",
|
51
|
+
# error_message: "Empty payment period found in PaymentConfiguration#create_continuous_payments",
|
52
|
+
# )
|
53
|
+
# else
|
54
|
+
# raise "Empty payment period found in PaymentConfiguration#create_continuous_payments"
|
55
|
+
# end
|
56
|
+
|
57
|
+
# C. With other options
|
58
|
+
HBW.notify(
|
59
|
+
"PaymentConfiguration",
|
60
|
+
"Empty payment period found in PaymentConfiguration#create_continuous_payments",
|
61
|
+
context: {
|
62
|
+
payment_config_id: id,
|
63
|
+
last_payment_id: last_payment.id
|
64
|
+
}
|
65
|
+
)
|
66
|
+
|
67
|
+
## equivalent code using `Honeybadger`
|
68
|
+
#
|
69
|
+
# if defined?(Honeybadger)
|
70
|
+
# Honeybadger.notify(
|
71
|
+
# error_class: "PaymentConfiguration",
|
72
|
+
# error_message: "Empty payment period found in PaymentConfiguration#create_continuous_payments",
|
73
|
+
# context: {
|
74
|
+
# payment_config_id: id,
|
75
|
+
# last_payment_id: last_payment.id
|
76
|
+
# }
|
77
|
+
# )
|
78
|
+
# else
|
79
|
+
# raise "Empty payment period found in PaymentConfiguration#create_continuous_payments"
|
80
|
+
# end
|
81
|
+
```
|
82
|
+
|
83
|
+
### `notifce_only` option
|
84
|
+
|
85
|
+
This option is default false.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
HBW.notify(ex, notice_only: true)
|
89
|
+
|
90
|
+
## equivalent code using `Honeybadger`
|
91
|
+
#
|
92
|
+
# if defined?(Honeybadger)
|
93
|
+
# Honeybadger.notify(ex, error_message: "[Notice Only] #{ex.class}: #{ex.message}")
|
94
|
+
# else
|
95
|
+
# raise "[Notice Only] #{ex.class}: #{ex.message}"
|
96
|
+
# end
|
97
|
+
|
98
|
+
HBW.notify("PaymentConfiguration", "Empty payment period found in PaymentConfiguration#create_continuous_payments", notice_only: true)
|
99
|
+
|
100
|
+
## equivalent code using `Honeybadger`
|
101
|
+
#
|
102
|
+
# if defined?(Honeybadger)
|
103
|
+
# Honeybadger.notify(
|
104
|
+
# error_class: "PaymentConfiguration",
|
105
|
+
# error_message: "[Notice Only] Notice: Empty payment period found in PaymentConfiguration#create_continuous_payments",
|
106
|
+
# )
|
107
|
+
# else
|
108
|
+
# raise "[Notice Only] Notice: Empty payment period found in PaymentConfiguration#create_continuous_payments"
|
109
|
+
# end
|
110
|
+
```
|
111
|
+
|
112
|
+
### `raise_development` option
|
113
|
+
|
114
|
+
This option is default true.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# `exception` is raised
|
118
|
+
[0] pry(main)> HBW.notify(RuntimeError.new("test error"))
|
119
|
+
RuntimeError: test error
|
120
|
+
|
121
|
+
# `exception` with specified `error_message` is raised
|
122
|
+
[1] pry(main)> HBW.notify("PaymentConfiguration", "Empty payment period found in PaymentConfiguration#create_continuous_payments")
|
123
|
+
RuntimeError: Empty payment period found in PaymentConfiguration#create_continuous_payments
|
124
|
+
|
125
|
+
# when `raise_development: false` is specified, no exception is raised
|
126
|
+
[2] pry(main)> HBW.notify(RuntimeError.new("test error"), raise_development: false)
|
127
|
+
=> nil
|
128
|
+
```
|
129
|
+
|
130
|
+
## Development
|
131
|
+
|
132
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
133
|
+
|
134
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
135
|
+
|
136
|
+
## Contributing
|
137
|
+
|
138
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/south37/hbw.
|
139
|
+
|
140
|
+
## License
|
141
|
+
|
142
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/rspec
ADDED
data/bin/setup
ADDED
data/hbw.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "hbw/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hbw"
|
8
|
+
spec.version = HBW::VERSION
|
9
|
+
spec.authors = ["Nao Minami"]
|
10
|
+
spec.email = ["south37777@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple wrapper of Honeybadger}
|
13
|
+
spec.description = %q{Simple wrapper of Honeybadger}
|
14
|
+
spec.homepage = "http://github.com/south37/hbw"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.7.0"
|
36
|
+
spec.add_development_dependency "pry"
|
37
|
+
end
|
data/lib/hbw/version.rb
ADDED
data/lib/hbw.rb
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
require "hbw/version"
|
2
|
+
|
3
|
+
module HBW
|
4
|
+
class ArgumentError < ::ArgumentError; end
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# @overload
|
8
|
+
#
|
9
|
+
# @param [Exception] exception
|
10
|
+
# @param [Hash, NilClass] option
|
11
|
+
# @example HBW.notify(exception)
|
12
|
+
# @example HBW.notify(exception, { error_class: 'InvalidUserError' })
|
13
|
+
# def notify(exception, option = nil)
|
14
|
+
#
|
15
|
+
# @param [Exception] exception
|
16
|
+
# @param [String] error_class
|
17
|
+
# @param [String] error_message
|
18
|
+
# @param [Hash] context
|
19
|
+
# @param [Array] backtrace
|
20
|
+
# @param [Hash] parameters
|
21
|
+
# @param [String] action
|
22
|
+
# @param [Boolean] raise_development
|
23
|
+
# @param [Boolean] notice_only
|
24
|
+
# @example HBW.notify(exception, error_class: 'InvalidUserError')
|
25
|
+
# def notify(exception, error_class: nil, error_message: nil, context: nil, backtrace: nil, parameters: nil, action: nil, raise_development: true, notice_only: false)
|
26
|
+
#
|
27
|
+
# @param [String] error_class
|
28
|
+
# @param [String] error_message
|
29
|
+
# @param [Hash] context
|
30
|
+
# @param [Array] backtrace
|
31
|
+
# @param [Hash] parameters
|
32
|
+
# @param [String] action
|
33
|
+
# @param [Boolean] raise_development
|
34
|
+
# @param [Boolean] notice_only
|
35
|
+
# @example HBW.notify('InvalidUserError', 'user message must be integer, but got #{user.id}', raise_development: false)
|
36
|
+
# def notify(error_class, error_message, context: nil, backtrace: nil, parameters: nil, action: nil, raise_development: true, notice_only: false)
|
37
|
+
def notify(exception_or_error_class, option_or_error_message = nil,
|
38
|
+
error_class: nil, error_message: nil, context: nil, backtrace: nil, parameters: nil, action: nil,
|
39
|
+
raise_development: true, notice_only: false)
|
40
|
+
if exception_or_error_class.is_a?(Exception)
|
41
|
+
# option_or_error_message must be option (Hash-like object)
|
42
|
+
if !(option_or_error_message.nil? || option_or_error_message.respond_to?(:to_hash))
|
43
|
+
raise HBW::ArgumentError.new("option_or_error_message must be nil or Hash-like object, but got #{option_or_error_message}")
|
44
|
+
end
|
45
|
+
if option_or_error_message.nil?
|
46
|
+
opts = {}
|
47
|
+
else
|
48
|
+
opts = option_or_error_message.to_hash
|
49
|
+
end
|
50
|
+
merge_opts!(opts,
|
51
|
+
error_class: error_class, error_message: error_message,
|
52
|
+
context: context, backtrace: backtrace, parameters: parameters, action: action, raise_development: raise_development, notice_only: notice_only)
|
53
|
+
notify_raw(exception_or_error_class, opts)
|
54
|
+
elsif exception_or_error_class.is_a?(String)
|
55
|
+
# option_or_error_message must be error_message (String)
|
56
|
+
if option_or_error_message.nil? || !option_or_error_message.respond_to?(:to_s)
|
57
|
+
raise HBW::ArgumentError.new("option_or_error_message must be String-like object, but got #{option_or_error_message}")
|
58
|
+
end
|
59
|
+
# error_class and error_message must be nil
|
60
|
+
if (!error_class.nil? || !error_message.nil?)
|
61
|
+
raise HBW::ArgumentError.new("error_class must be nil but got #{error_class}, error_message must be nil but got #{error_message}")
|
62
|
+
end
|
63
|
+
opts = {}
|
64
|
+
merge_opts!(opts,
|
65
|
+
error_class: exception_or_error_class, error_message: option_or_error_message,
|
66
|
+
context: context, backtrace: backtrace, parameters: parameters, action: action, raise_development: raise_development, notice_only: notice_only)
|
67
|
+
notify_raw(opts)
|
68
|
+
else
|
69
|
+
raise HBW::ArgumentError.new("Invalid argument")
|
70
|
+
end
|
71
|
+
|
72
|
+
rescue => e
|
73
|
+
if should_use_honeybadger?
|
74
|
+
# Note: Something wrong. exception must not occur when
|
75
|
+
# should_use_honeybadger? is true.
|
76
|
+
honeybadger_notify(e)
|
77
|
+
return nil
|
78
|
+
else
|
79
|
+
raise e
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# raise_development is supported. By default, raise_development is true.
|
84
|
+
# notice_only is supported. By default, notice_only is false.
|
85
|
+
# @param [Exception, Hash] exception_or_opts
|
86
|
+
# @param [Hash] opts
|
87
|
+
# @return [NilClass]
|
88
|
+
# @raise [RuntimeError]
|
89
|
+
def notify_raw(exception_or_opts, opts = {})
|
90
|
+
opts.merge!(exception_or_opts.to_hash) if exception_or_opts.respond_to?(:to_hash)
|
91
|
+
raise_development = opts.has_key?(:raise_development) ? opts.delete(:raise_development) : true
|
92
|
+
notice_only = opts.has_key?(:notice_only) ? opts.delete(:notice_only) : false
|
93
|
+
|
94
|
+
if notice_only
|
95
|
+
opts[:error_message] = "[Notice Only] #{error_class(exception_or_opts, opts)}: #{error_message(exception_or_opts, opts)}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# QA, Production
|
99
|
+
if should_use_honeybadger?
|
100
|
+
if exception_or_opts.respond_to?(:to_hash) # Already merged to opts
|
101
|
+
honeybadger_notify(opts)
|
102
|
+
else
|
103
|
+
honeybadger_notify(exception_or_opts, opts)
|
104
|
+
end
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
|
108
|
+
# Development
|
109
|
+
return nil if !raise_development
|
110
|
+
|
111
|
+
if notice_only
|
112
|
+
raise opts[:error_message]
|
113
|
+
else
|
114
|
+
raise exception_or_error_message(exception_or_opts, opts)
|
115
|
+
end
|
116
|
+
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
def merge_opts!(opts, error_class:, error_message:, context:, backtrace:, parameters:, action:, raise_development:, notice_only:)
|
123
|
+
opts.merge!(error_class: error_class) if !error_class.nil?
|
124
|
+
opts.merge!(error_message: error_message) if !error_message.nil?
|
125
|
+
opts.merge!(context: context) if !context.nil?
|
126
|
+
opts.merge!(backtrace: backtrace) if !backtrace.nil?
|
127
|
+
opts.merge!(parameters: parameters) if !parameters.nil?
|
128
|
+
opts.merge!(action: action) if !action.nil?
|
129
|
+
opts.merge!(
|
130
|
+
raise_development: raise_development,
|
131
|
+
notice_only: notice_only,
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
# @return [Boolean]
|
136
|
+
def should_use_honeybadger?
|
137
|
+
defined?(Honeybadger)
|
138
|
+
end
|
139
|
+
|
140
|
+
# @param [Exception, Hash] exception_or_opts
|
141
|
+
# @param [Hash] opts
|
142
|
+
def honeybadger_notify(exception_or_opts, opts = {})
|
143
|
+
::Honeybadger.notify(exception_or_opts, opts)
|
144
|
+
end
|
145
|
+
|
146
|
+
# @param [Exception, Hash] exception_or_opts
|
147
|
+
# @param [Hash] opts
|
148
|
+
# @return [String] error class
|
149
|
+
def error_class(exception_or_opts, opts)
|
150
|
+
if exception_or_opts.is_a?(Exception)
|
151
|
+
exception_or_opts.class.name
|
152
|
+
else
|
153
|
+
'Notice'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# @param [Exception, Hash] exception_or_opts
|
158
|
+
# @param [Hash] opts
|
159
|
+
# @return [String] error message
|
160
|
+
def error_message(exception_or_opts, opts)
|
161
|
+
e = exception_or_error_message(exception_or_opts, opts)
|
162
|
+
if e.is_a?(Exception)
|
163
|
+
e.message
|
164
|
+
else
|
165
|
+
e
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# @param [Exception, Hash] exception_or_opts
|
170
|
+
# @param [Hash] opts
|
171
|
+
# @return [Exception, String] exception or error message
|
172
|
+
def exception_or_error_message(exception_or_opts, opts)
|
173
|
+
if exception_or_opts.is_a?(Exception)
|
174
|
+
exception_or_opts
|
175
|
+
elsif exception_or_opts.respond_to?(:to_hash) && (opts[:exception] || opts[:error_message])
|
176
|
+
opts[:exception] || opts[:error_message]
|
177
|
+
else
|
178
|
+
exception_or_opts.to_s
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hbw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nao Minami
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.7.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Simple wrapper of Honeybadger
|
70
|
+
email:
|
71
|
+
- south37777@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/rspec
|
86
|
+
- bin/setup
|
87
|
+
- hbw.gemspec
|
88
|
+
- lib/hbw.rb
|
89
|
+
- lib/hbw/version.rb
|
90
|
+
homepage: http://github.com/south37/hbw
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
allowed_push_host: https://rubygems.org
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.7.3
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Simple wrapper of Honeybadger
|
115
|
+
test_files: []
|