kidpollo / tanker

IndexTank Integration with your fav ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught exception when searching and index tank isn't available

joeljunstrom opened this issue · comments

If index tank can not be reached (or do not have the index supplied or give any other error) a search will throw an uncaught exception.

The problem is that tanker always expects the response hash to contain 'results'.

    results = index_result['results']
    return [] if results.empty?

The solution is of course simple

    results = index_result['results']
    return [] if results.nil? || results.empty?

In production you do not want your app to get an error when your search is down but in development it would be nice to see the error. Me and @arvida was discussing that maybe we should have some sort of general handling for communication exceptions? (log, send with hoptoad if available or so)

Mainly want to take it up for discussion, I can send a pull request for just fixing so it fails silently if you think that is enough for now.

Yo actually pose a very valid concern tho I think this is a delicate matter because I dont want the gem to depend on Rails so selecting this mechanism can be tricky.

Any preference?

I think we could use RACK_ENV (should be enough for most ruby webframeworks?) to check if we're running in production or not.
If we're running in production we just:

  • check if we got a Rails logging object
    • Yes: write error to rails log
    • No: create a Logger object and write error to logs/tanker.log
  • check if Hoptoad is setup
    • Yes: send a hoptoad notification with error

If we're not in production we just let the error raise.

What you think?

sounds interesting, I will get to this as soon as I can but pull requests are more than welcome :P

cool =)
we'll try and get some code done for this over the next week

Are you still having problems? if not can you close this issue?

Haven't had any time to look in to this yet... Too much work ;(
I'll close it for now.

yes no problem I have been busy also but I am trying to add the category feature out there really soon!