Sha256: 7257cd01a5d8483e025b2748bf5e39ca8eb769477f3025d096c6248486499742

Contents?: true

Size: 656 Bytes

Versions: 6

Compression:

Stored size: 656 Bytes

Contents

module BlockScore
  class BlockscoreError < StandardError

    attr_reader :message
    attr_reader :error_type
    attr_reader :http_status
    attr_reader :json_body

    def initialize(message=nil, json_body=nil, http_status="400",
                    error_type="invalid_request_error")
      super(message)

      message_desc = "#{json_body["error"]["param"]} #{json_body["error"]["code"]}"

      @error_type = error_type 
      @http_status = http_status
      @json_body = json_body
      @message = "#{message} (#{message_desc})"
    end

    def to_s
      "Status: #{@http_status}. Type: #{@error_type}, Message: #{@message}"
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blockscore-4.0.0 lib/blockscore/error/blockscore_error.rb
blockscore-3.0.1 lib/blockscore/error/blockscore_error.rb
blockscore-3.0.0 lib/blockscore/error/blockscore_error.rb
blockscore-2.1.2 lib/blockscore/error/blockscore_error.rb
blockscore-2.1.1 lib/blockscore/error/blockscore_error.rb
blockscore-2.1.0 lib/blockscore/error/blockscore_error.rb