Sha256: 51e46afa76d720cc178dd250f04dfaf89fd53551a42b77d1a9ee5d43fdc54162

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

module VulnDBHQ
  module Error
    # Raised when VulnDBHQ returns a 4xx HTTP status code or there's an error in Faraday
    class ClientError < Base

      # Create a new error from an HTTP environment
      #
      # @param body [Hash]
      # @return [VulnDBHQ::Error]
      def self.from_response_body(body)
        new(parse_error(body))
      end

      private

      def self.parse_error(body)
        if body.nil?
          ''
        elsif body[:message]
          body[:message]
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vulndbhq-0.1.1 lib/vulndbhq/error/client_error.rb
vulndbhq-0.1.0 lib/vulndbhq/error/client_error.rb