Sha256: 3cc8030b438486632d29ff7d32caa381e3c2ae9a575a545e0d4a641107ee93ea

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Yammer
  module Error

    class << self
      def from_status(status=nil)
        case status
        when 400
          BadRequest
        when 401
          Unauthorized
        when 403
          Forbidden
        when 404
          NotFound
        when 406
          NotAcceptable
        when 429
          RateLimitExceeded
        when 500
          InternalServerError
        when 502
          BadGateway
        when 503
          ServiceUnavailable
        else
          ApiError
        end
      end
    end

    # Raised when Yammer returns unknown HTTP status code
    class ApiError < StandardError;  end

    # Raised when Yammer returns the HTTP status code 400
    class BadRequest < ApiError; end

    # Raised when Yammer returns the HTTP status code 401
    class Unauthorized < ApiError; end

    # Raised when Yammer returns the HTTP status code 403
    class Forbidden < ApiError; end

    # Raised when Yammer returns the HTTP status code 404
    class NotFound < ApiError; end

    # Raised when Yammer returns the HTTP status code 406
    class NotAcceptable < ApiError; end

    # Raised when Yammer returns the HTTP status code 429
    class RateLimitExceeded < ApiError; end

    # Raised when Yammer returns the HTTP status code 500
    class InternalServerError < ApiError; end

    # Raised when Yammer returns the HTTP status code 502
    class BadGateway < ApiError; end

    # Raised when Yammer returns the HTTP status code 503
    class ServiceUnavailable < ApiError; end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
yammer-client-0.1.8 lib/yammer/error.rb
yammer-client-0.1.7 lib/yammer/error.rb
yammer-client-0.1.6 lib/yammer/error.rb
yammer-client-0.1.5 lib/yammer/error.rb
yammer-client-0.1.4 lib/yammer/error.rb
yammer-client-0.1.3 lib/yammer/error.rb
yammer-client-0.1.2 lib/yammer/error.rb
yammer-client-0.1.1 lib/yammer/error.rb
yammer-client-0.1.0 lib/yammer/error.rb