algoliasearch-rails icon indicating copy to clipboard operation
algoliasearch-rails copied to clipboard

How should we handle exceptions?

Open Spone opened this issue 5 years ago • 3 comments

The README mentions how to disable exceptions, but not how we should handle them properly, for instance in production. I do not want my update to break if the record is too large for instance.

I'd like to see examples of a recommended way of rescueing errors when setting up indexation on my model. I think mentioning it explicitly will encourage developers to handle exceptions properly, and prevent it to blow up in production when they do not expect it.

It would be awesome if we could use rescue right in the config block, such as this:

class Contact < ActiveRecord::Base
  include AlgoliaSearch

  algoliasearch do
    attribute :first_name, :last_name, :email
  rescue Algolia::AlgoliaProtocolError => e
    # handle exception properly
  end
end

Spone avatar Mar 22 '19 10:03 Spone

@Spone Have you figured out how to accomplish this? I am looking to log Algolia exceptions to Sentry without breaking the application in production when Algolia cannot be reached.

pacarvalho avatar Jul 23 '20 13:07 pacarvalho

@pacarvalho nope :(

Sadly, Algolia is failing its Rails users right now... very few updates here... ping @chloelbn @redox

Spone avatar Jul 23 '20 13:07 Spone

I also need this!

andresespinosapc avatar Oct 13 '20 15:10 andresespinosapc