Sha256: 41a4b602e97e86bedbe0629728089cf5ba00f8350b986b545e25c213a1eae50d
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require "http/exceptions/version" require "http/exceptions/http_exception" module Http module Exceptions EXCEPTIONS = [ SocketError, Errno::ETIMEDOUT, (Net.const_defined?(:ReadTimeout) ? Net::ReadTimeout : EOFError), (Net.const_defined?(:OpenTimeout) ? Net::ReadTimeout : EOFError), Net::ProtocolError, Errno::ECONNREFUSED, Errno::EHOSTDOWN, Errno::ECONNRESET, OpenSSL::SSL::SSLError, EOFError, ].freeze def self.wrap_exception begin yield rescue *Exceptions::EXCEPTIONS => e raise HttpException.new original_exception: e end end def self.check_response!(res) raise HttpException.new(response: res) unless (200...300).include?(res.code) res end def self.wrap_and_check wrap_exception do check_response! yield end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
http-exceptions-0.0.3 | lib/http/exceptions.rb |