Yandex-cleanweb fails to handle invalid response from Yandex.Cleanweb the service
When the response comes in invalid, yandex-cleanweb fails with the following:
NoMethodError: undefined method `content' for nil:NilClass
File "/home/amplifr/amplifr/shared/bundle/ruby/2.0.0/bundler/gems/yandex-cleanweb-f244a29261a2/lib/yandex_cleanweb.rb" line 22 in spam?
So my guess is that api_check_spam should check if the response is 200, and if it's not, an exception should be thrown. spam? should handle the exception and have an optional parameter of the default policy whether it should consider messages that failed to be tested as spam or not. If no such parameter is provided, spam? should consider these messages as valid, non-spam messages.
Do you have an example of invalid query?
ping @xnutsive
Nope, no examples.
We send params[something] to spam?, so there might be some junk, however I don't think the reason of the failure is in example — it might be network issues or whatever else.
Do you think it's a good idea to handle those exceptions inside spam?? We can actually rescue those in our code and it'd still work ok for us.
You're right, I need to add custom exception that will be raised in case if non-200 response code.
@xnutsive done. I've released 0.0.6 which raises YandexCleanweb::BadResponseException in case of empty response.