Sha256: 55d3f4c39bba93f88b22b488e9f7aec82e0eb7e7eb1771b032a5917f1216191a

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 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 < DiscourseError
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse_api-0.47.0 lib/discourse_api/error.rb
discourse_api-0.46.0 lib/discourse_api/error.rb