Sha256: 7722d2bee0cc07dc0dbbd25c21c37b611f4422f2b7f766fe32178b966b5133b8

Contents?: true

Size: 790 Bytes

Versions: 16

Compression:

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
discourse_api-0.45.1 lib/discourse_api/error.rb
discourse_api-0.45.0 lib/discourse_api/error.rb
discourse_api-0.44.0 lib/discourse_api/error.rb
discourse_api-0.43.1 lib/discourse_api/error.rb
discourse_api-0.43.0 lib/discourse_api/error.rb
discourse_api-0.42.0 lib/discourse_api/error.rb
discourse_api-0.41.0 lib/discourse_api/error.rb
discourse_api-0.40.0 lib/discourse_api/error.rb
discourse_api-0.39.3 lib/discourse_api/error.rb
discourse_api-0.39.2 lib/discourse_api/error.rb
discourse_api-0.39.1 lib/discourse_api/error.rb
discourse_api-0.39.0 lib/discourse_api/error.rb
discourse_api-0.38.0 lib/discourse_api/error.rb
discourse_api-0.37.0 lib/discourse_api/error.rb
discourse_api-0.36.0 lib/discourse_api/error.rb
discourse_api-0.35.0 lib/discourse_api/error.rb