Sha256: c78739b6edc7c55dfa86b27da2ab9945c53609b51562298cf066cf1c30227101

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'cloud_party/exception'
require 'cloud_party/exceptions/request_errors'
module CloudParty
  module Errors

    ##
    # ### ConnectionError
    class ConnectionError < StandardError
      attr_reader :response

      def initialize(message, response)
        super(message)
        @response = response
      end
    end

    class UnknownError < RequestError
      def initialize(message, method, endpoint, code, response)
        super
      end

      def error_string
        <<~HEREDOC
          An error with the request has occurred, please make
          sure the method verb, endpoint, and credentials are
          correct for this request.
        HEREDOC
      end

      def extra_string
        <<~HEREDOC
          Credentials Context: #{@obj&.class&.cfg}

          Method Verb: #{@method}
          Endpoint: #{@endpoint}
          HTTP Status Code: #{@code}
          Response Body: #{@response&.body}
        HEREDOC
      end
    end
    autoload :UnRecognizedResultTypeError, 'cloud_party/exceptions/un_recognized_result_type_error'
    autoload :UnRecognizedEndpointError, 'cloud_party/exceptions/un_recognized_endpoint_error'

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloud_party-0.1.7 lib/cloud_party/exceptions.rb
cloud_party-0.1.6 lib/cloud_party/exceptions.rb