Sha256: d850e2ff4f395b8a786eaabf5c8aca5cefaf38f6edb19dea0c4c618458c8ca47

Contents?: true

Size: 740 Bytes

Versions: 8

Compression:

Stored size: 740 Bytes

Contents

require "digicert/errors/request_error"
require "digicert/errors/forbidden"
require "digicert/errors/server_error"
require "digicert/errors/unauthorized"

module Digicert
  module Errors
    def self.server_errors
      [
        OpenSSL::SSL::SSLError,
        Errno::ETIMEDOUT,
        Errno::EHOSTUNREACH,
        Errno::ENETUNREACH,
        Errno::ECONNRESET,
        Net::OpenTimeout,
        SocketError,
        Net::HTTPServerError,
      ]
    end

    def self.error_klass_for(response)
      case response
      when *server_errors then Errors::ServerError
      when Net::HTTPUnauthorized then Errors::Unauthorized
      when Net::HTTPForbidden then Errors::Forbidden
      else Errors::RequestError
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
digicert-1.0.0 lib/digicert/errors.rb
digicert-0.5.0 lib/digicert/errors.rb
digicert-0.4.1 lib/digicert/errors.rb
digicert-0.4.0 lib/digicert/errors.rb
digicert-0.3.1 lib/digicert/errors.rb
digicert-0.3.0 lib/digicert/errors.rb
digicert-0.2.0 lib/digicert/errors.rb
digicert-0.1.2 lib/digicert/errors.rb