Sha256: d3f80c7d5f713a385f7cc32cfa013182f61c16142e04cf06c5331dc2062a685e

Contents?: true

Size: 894 Bytes

Versions: 11

Compression:

Stored size: 894 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module EML
  # RESTError is the parent class for errors related to connections to the EML
  # REST Web Services APIs
  class RESTError < Error
    extend T::Sig

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

      @response = T.let(response, T.nilable(EML::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 url
      @response&.url&.to_s
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eml-3.0.0 lib/eml/error/rest.rb
eml-2.2.0 lib/eml/error/rest.rb
eml-2.1.8 lib/eml/error/rest.rb
eml-2.1.7 lib/eml/error/rest.rb
eml-2.1.6 lib/eml/error/rest.rb
eml-2.1.5 lib/eml/error/rest.rb
eml-2.1.4 lib/eml/error/rest.rb
eml-2.1.3 lib/eml/error/rest.rb
eml-2.1.2 lib/eml/error/rest.rb
eml-2.1.1 lib/eml/error/rest.rb
eml-2.1.0 lib/eml/error/rest.rb