Sha256: 9dbc8c2a2193e7586d9a83ce10f4195e479f9f7a16e26b20973687f1a6eca4f6

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

module RDStation

  class Error < StandardError
    attr_reader :details, :http_status, :headers, :body

    def initialize(details)
      @details = details
      message = details['error_message']
      raise ArgumentError, 'The details hash must contain an error message' unless message

      # Those three arguments are kept only for compatibility reasons.
      # They aren't needed since we can get them directly in the details hash.
      # Consider removing them when update the major version.
      @http_status = details['http_status']
      @headers = details['headers']
      @body = details['body']

      super(message)
    end

    class ConflictingField < Error; end
    class Default < Error; end
    class ExpiredAccessToken < Error; end
    class ExpiredCodeGrant < Error; end
    class InvalidCredentials < Error; end
    class InvalidEventType < Error; end
    class ResourceNotFound < Error; end
    class Unauthorized < Error; end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rdstation-ruby-client-1.2.1 lib/rdstation/error.rb
rdstation-ruby-client-1.2.0 lib/rdstation/error.rb
rdstation-ruby-client-1.1.0 lib/rdstation/error.rb