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
- EXCEPTIONS =
[ SocketError, Errno::ETIMEDOUT, (Net.const_defined?(:ReadTimeout) ? Net::ReadTimeout : EOFError), (Net.const_defined?(:OpenTimeout) ? Net::OpenTimeout : EOFError), Net::ProtocolError, Errno::ECONNREFUSED, Errno::EHOSTDOWN, Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::ECONNABORTED, OpenSSL::SSL::SSLError, EOFError, ].freeze
- VERSION =
"0.1.0"
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
31 32 33 34 |
# File 'lib/http/exceptions.rb', line 31 def self.check_response!(res) raise HttpException.new(response: res) unless (200...300).include?(res.code) res end |
.configuration ⇒ Object
The configuration object.
56 57 58 |
# File 'lib/http/exceptions.rb', line 56 def self.configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
49 50 51 52 |
# File 'lib/http/exceptions.rb', line 49 def self.configure yield(configuration) self end |
.wrap_and_check ⇒ Object
36 37 38 39 40 |
# File 'lib/http/exceptions.rb', line 36 def self.wrap_and_check wrap_exception do check_response! yield end end |
.wrap_exception ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/http/exceptions.rb', line 23 def self.wrap_exception begin yield rescue *configuration.exceptions_to_convert => e raise HttpException.new original_exception: e end end |