~tim/wuparty

2406d88a414164af2e76d5b70ac8a111b7c05759 — Tim Morgan 7 years ago 4c15a98
Catch JSON parse error.
1 files changed, 5 insertions(+), 0 deletions(-)

M lib/wuparty.rb
M lib/wuparty.rb => lib/wuparty.rb +5 -0
@@ 181,6 181,11 @@ class WuParty
      options.merge!(:basic_auth => {:username => @api_key})
      url = "#{base_url}/#{action}.json"
      result = self.class.send(verb, url, options)
      begin
        result.to_s # trigger parse error if possible
      rescue MultiJson::DecodeError => e
        raise HTTPError.new(500, e.message)
      end
      if result.is_a?(String)
        raise ConnectionError, result
      elsif result['HTTPCode']