lib/algolia/error.rb in algolia-3.0.0.beta.10 vs lib/algolia/error.rb in algolia-3.0.0.beta.11

- old
+ new

@@ -8,9 +8,19 @@ 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.