Sha256: c46f565982a9b8a9b19c0e43add0c1626516aed3bd697744d992b3dd45ca1308

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

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(message, method, endpoint, code, body)
        super(message)
        @method   = method
        @endpoint = endpoint
        @code     = code
        @body = body
      end

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

      def extra_string
        # This method should be overridden
      end

      # override error_string to provide your own error_string
      def error_string
        # This method should be overridden
      end
    end
    class InputError < ArgumentError
      attr_reader :input, :obj
      # @param [String] message message
      # @param [Object] obj object
      # @param [String] input input string
      def initialize(message, obj, input)
        super(message)
        @obj = obj
        @input = input
      end
    end
    class NoDefinedZoneError < StandardError
      attr_reader :obj
      def initialize(message, obj)
        super(message)
        @obj = obj
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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