Module: Http::Exceptions
- Defined in:
- lib/http/exceptions.rb,
lib/http/exceptions/version.rb,
lib/http/exceptions/configuration.rb,
lib/http/exceptions/http_exception.rb
Defined Under Namespace
Classes: Configuration, HttpException
Constant Summary collapse
- VERSION =
'0.1.6'.freeze
Class Method Summary collapse
- .check_response!(res) ⇒ Object
-
.configuration ⇒ Object
The configuration object.
-
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
- .wrap_and_check ⇒ Object
- .wrap_exception ⇒ Object
Class Method Details
.check_response!(res) ⇒ Object
15 16 17 18 |
# File 'lib/http/exceptions.rb', line 15 def self.check_response!(res) raise HttpException.new(response: res) unless (200...300).include?(res.code.to_i) res end |
.configuration ⇒ Object
The configuration object.
40 41 42 |
# File 'lib/http/exceptions.rb', line 40 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
33 34 35 36 |
# File 'lib/http/exceptions.rb', line 33 def self.configure yield(configuration) self end |
.wrap_and_check ⇒ Object
20 21 22 23 24 |
# File 'lib/http/exceptions.rb', line 20 def self.wrap_and_check wrap_exception do check_response! yield end end |
.wrap_exception ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/http/exceptions.rb', line 7 def self.wrap_exception begin yield rescue *configuration.exceptions_to_convert => e raise HttpException.new original_exception: e end end |