Sha256: b486513558f3f3c0274272b978aae5b400f017d852510c8c4880a1d9ee6c9d60

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module CloudParty
  module Errors
    class APIError < StandardError
      attr_reader(:response)
      def initialize(message, response)
        super(message)
        @response = response
      end
    end
    class RequestError < StandardError
      def initialize(obj:, method:, code:, response:, endpoint:)
        @obj      = obj
        @method   = method
        @endpoint = endpoint
        @code     = code
        @response = response
      end

      def to_s
        [error_string.squish, extra_string].join("\n")
      end

      def self.extra_string
        # This method should be overridden
      end

      # override error_string to provide your own error_string
      def self.error_string
        # This method should be overridden
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloud_party-0.1.5 lib/cloud_party/exception.rb
cloud_party-0.1.4 lib/cloud_party/exception.rb
cloud_party-0.1.3 lib/cloud_party/exception.rb
cloud_party-0.1.2 lib/cloud_party/exception.rb
cloud_party-0.1.1 lib/cloud_party/exception.rb