Sha256: 9f387c18c2048ec1f73fede7ff06d0f25a46a2af9c634c11538763df9814df64

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 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, EML::Response)
    end

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

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

    sig { returns(Integer) }
    def http_status
      @response.status
    end

    sig { returns(String) }
    def url
      @response.url.to_s
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eml-2.0.0 lib/eml/error/rest.rb
eml-1.0.0 lib/eml/error/rest.rb