watson-ruby icon indicating copy to clipboard operation
watson-ruby copied to clipboard

Not sure if 401 is the only code that gives nonparseable body? [lib/watson/remote.rb]

Open nhmood opened this issue 11 years ago • 0 comments

filename : lib/watson/remote.rb line # : 109 tag : fix md5 : b547385b20a5543b644943e810e1af76

            # [fix] - Not sure if 401 is the only code that gives nonparseable body? 
            # Figure out what other response codes are bad news for JSON.parse
            _json = _resp.code == "401" ? Hash.new :  JSON.parse(_resp.body)
            debug_print "JSON: \n #{ _json }\n"

            # [review] - Returning hash of json + response the right thing to do?
            # return {:json => _json, :resp => _resp}
            return _json, _resp 
        end
    end
    end
end

nhmood avatar Nov 21 '13 16:11 nhmood