Sha256: 903207eda4af4f93703015ba1ec3a57e60297a49acc5bc0f0c7637ebedad7f2f

Contents?: true

Size: 1.08 KB

Versions: 31

Compression:

Stored size: 1.08 KB

Contents

module Algolia
  # Base exception class for errors thrown by the Algolia
  # client library. AlgoliaError will be raised by any
  # network operation if Algolia.init() has not been called.
  # Exception ... why? A:http://www.skorks.com/2009/09/ruby-exceptions-and-exception-handling/
  #
  class AlgoliaError < StandardError
  end

  # Used when hosts are unreachable
  #
  class AlgoliaUnreachableHostError < AlgoliaError
    attr_reader :errors

    def initialize(message, errors = [])
      errors.last&.tap do |last_error|
        message += " Last error for #{last_error[:host]}: #{last_error[:error]}"
      end

      super(message)
      @errors = errors
    end
  end

  # An exception class raised when the REST API returns an error.
  # The error code and message will be parsed out of the HTTP response,
  # which is also included in the response attribute.
  #
  class AlgoliaHttpError < AlgoliaError
    attr_accessor :code, :message

    def initialize(code, message)
      self.code = code
      self.message = message
      super("#{self.code()}: #{self.message()}")
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
algolia-3.8.1 lib/algolia/error.rb
algolia-3.8.0 lib/algolia/error.rb
algolia-3.7.1 lib/algolia/error.rb
algolia-3.7.0 lib/algolia/error.rb
algolia-3.6.0 lib/algolia/error.rb
algolia-3.5.4 lib/algolia/error.rb
algolia-3.5.3 lib/algolia/error.rb
algolia-3.5.2 lib/algolia/error.rb
algolia-3.5.1 lib/algolia/error.rb
algolia-3.5.0 lib/algolia/error.rb
algolia-3.4.0 lib/algolia/error.rb
algolia-3.3.4 lib/algolia/error.rb
algolia-3.3.3 lib/algolia/error.rb
algolia-3.3.2 lib/algolia/error.rb
algolia-3.3.1 lib/algolia/error.rb
algolia-3.3.0 lib/algolia/error.rb
algolia-3.2.4 lib/algolia/error.rb
algolia-3.2.3 lib/algolia/error.rb
algolia-3.2.2 lib/algolia/error.rb
algolia-3.2.1 lib/algolia/error.rb