Sha256: 42813123828389254ad947f2c5a05e78c41ca7bce1ff3f3571572e3ad5821f5a

Contents?: true

Size: 599 Bytes

Versions: 8

Compression:

Stored size: 599 Bytes

Contents

require "digicert/config"

module Digicert
  module Errors
    class RequestError < StandardError
      def initialize(msg = {})
        @msg = msg
        super msg
      end

      def message
        <<-MSG.gsub(/^ {8}/, "")
        #{explanation}:
        #{response_body}
        MSG
      end

      def explanation
        "A request to Digicert API failed"
      end

      def kind
        response_body.fetch("code", {})
      end

      private

      attr_reader :msg

      def response_body
        JSON[msg]
      rescue {}
      end
    end
  end

  Error = Errors::RequestError
end

Version data entries

8 entries across 8 versions & 1 rubygems

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