Sha256: d379a0453902051f4e6aa21422310a0aa81f8bb34c40324bfe6555d726e81293

Contents?: true

Size: 821 Bytes

Versions: 12

Compression:

Stored size: 821 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module DearInventory
  class RequestError < Error
    extend T::Sig

    sig do
      params(
        message: T.nilable(String),
        response: T.nilable(DearInventory::Response)
      ).void
    end
    def initialize(message = nil, response = nil)
      super(message)

      @response = T.let(response, T.nilable(DearInventory::Response))
    end

    sig { returns(T.nilable(String)) }
    def http_body
      @response&.error || @response&.body&.to_s
    end

    sig { returns(T.nilable(T::Hash[Symbol, String])) }
    def http_headers
      @response&.headers
    end

    sig { returns(T.nilable(Integer)) }
    def http_status
      @response&.http_status
    end

    sig { returns(T.nilable(String)) }
    def uri
      @response&.uri&.to_s
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dear_inventory-0.7.3 lib/dear_inventory/errors/request.rb
dear_inventory-0.7.2 lib/dear_inventory/errors/request.rb
dear_inventory-0.7.1 lib/dear_inventory/errors/request.rb
dear_inventory-0.7.0 lib/dear_inventory/errors/request.rb
dear_inventory-0.6.3 lib/dear_inventory/errors/request.rb
dear_inventory-0.6.2 lib/dear_inventory/errors/request.rb
dear_inventory-0.6.1 lib/dear_inventory/errors/request.rb
dear_inventory-0.6.0 lib/dear_inventory/errors/request.rb
dear_inventory-0.5.0 lib/dear_inventory/errors/request.rb
dear_inventory-0.4.1 lib/dear_inventory/errors/request.rb
dear_inventory-0.4.0 lib/dear_inventory/errors/request.rb
dear_inventory-0.3.0 lib/dear_inventory/errors/request.rb