Sha256: ec5f1f9e9919334a32a5849f6d4a89b177af0511314d390bf542f18474570197

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 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
    class UnknownError < 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

1 entries across 1 versions & 1 rubygems

Version Path
rdstation-ruby-client-2.3.1 lib/rdstation/error.rb