Sha256: 7e63b5da830f81ee68f01cb43ed8f5cb812eb5734e2f529b1867ce6afaf90963

Contents?: true

Size: 821 Bytes

Versions: 6

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true
module DiscourseApi
  class DiscourseError < StandardError
    attr_reader :response

    def initialize(message, response = nil)
      super(message)
      @response = response
    end
  end

  class Error < DiscourseError
    attr_reader :wrapped_exception

    # Initializes a new Error object
    #
    # @param exception [Exception, String]
    # @return [DiscourseApi::Error]
    def initialize(exception = $!)
      @wrapped_exception = exception
      exception.respond_to?(:message) ? super(exception.message) : super(exception.to_s)
    end
  end

  class UnauthenticatedError < DiscourseError
  end

  class NotFoundError < DiscourseError
  end

  class UnprocessableEntity < DiscourseError
  end

  class TooManyRequests < DiscourseError
  end

  class Timeout < Error
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
discourse_api-2.0.1 lib/discourse_api/error.rb
discourse_api-2.0.0 lib/discourse_api/error.rb
discourse_api-1.1.0 lib/discourse_api/error.rb
discourse_api-1.0.0 lib/discourse_api/error.rb
discourse_api-0.48.1 lib/discourse_api/error.rb
discourse_api-0.48.0 lib/discourse_api/error.rb