Sha256: 408abc1872f881dee4e216bc84c61b7c3b098d0dc1cae47aab961dd4e78013b4

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

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

      super(message)
    end

    class BadRequest < Error; end
    class Unauthorized < Error; end
    class Forbidden < Error; end
    class NotFound < Error; end
    class MethodNotAllowed < Error; end
    class NotAcceptable < Error; end
    class Conflict < Error; end
    class UnsupportedMediaType < Error; end
    class UnprocessableEntity < Error; end
    class InternalServerError < Error; end
    class NotImplemented < Error; end
    class BadGateway < Error; end
    class ServiceUnavailable < Error; end
    class ServerError < Error; end

    # 400 - Bad Request
    class ConflictingField < BadRequest; end
    class InvalidEventType < BadRequest; end

    # 401 - Unauthorized
    class ExpiredAccessToken < Unauthorized; end
    class ExpiredCodeGrant < Unauthorized; end
    class InvalidCredentials < Unauthorized; end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rdstation-ruby-client-2.3.0 lib/rdstation/error.rb
rdstation-ruby-client-2.2.0 lib/rdstation/error.rb
rdstation-ruby-client-2.1.0 lib/rdstation/error.rb
rdstation-ruby-client-2.0.0 lib/rdstation/error.rb