twingly / twingly-search-api-ruby

:gem: Twingly Blog Search API in Ruby
https://developer.twingly.com/
MIT License
4 stars 0 forks source link

Handle non-XML responses from server #31

Closed jage closed 8 years ago

jage commented 8 years ago

I got this error during a server restart, my guess is that HAProxy (that sits in front of the Search API) or IIS/Search API responded with non-XML.

/Users/jage/Source/twingly-analytics-api-ruby/lib/twingly/search/parser.rb:13:in `parse': undefined method `value' for nil:NilClass (NoMethodError)
    from /Users/jage/Source/twingly-analytics-api-ruby/lib/twingly/search/client.rb:24:in `execute_query'
    from /Users/jage/Source/twingly-analytics-api-ruby/lib/twingly/search/query.rb:17:in `execute'
    from find_all_posts_mentioning_github.rb:14:in `block in each'
    from find_all_posts_mentioning_github.rb:13:in `loop'
    from find_all_posts_mentioning_github.rb:13:in `each'
    from find_all_posts_mentioning_github.rb:27:in `<main>'

HAProxy responds with the following during server errors:

HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

Maybe that could be used as a fixture in the specs?