filestack / filestack-ruby

Official Ruby SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
Apache License 2.0
34 stars 27 forks source link

Rescues JSON::ParserError and raises body message on upload #69

Closed gdomingu closed 4 years ago

gdomingu commented 4 years ago

This is to handle case of when Filestack does not return JSON, but instead returns a plain response.

Example error trace:

JSON::ParserError: 435: unexpected token at 'uuid=API-F21xxxxxxxxx] Invalid response when trying to read from http://internal-taskrouters-int-lb-253xxxx.us-east-1.elb.amazonaws.com/output=format:jpg/imVQOBnKTVxxxxx' (Most recent call first)
Hide 4 non-project frames
File /data/xxx/shared/bundled_gems/ruby/2.4.0/gems/json-2.3.1/lib/json/common.rb line 263 in parse
File /data/xxx/shared/bundled_gems/ruby/2.4.0/gems/json-2.3.1/lib/json/common.rb line 263 in parse
File /data/xxx/shared/bundled_gems/ruby/2.4.0/gems/filestack-2.6.7/lib/filestack/utils/utils.rb line 97 in send_upload
File /data/xxxshared/bundled_gems/ruby/2.4.0/gems/filestack-2.6.7/lib/filestack/models/filestack_client.rb line 41 in upload
coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.01%) to 96.634% when pulling 0508846976ec8bafb3b339ffd0a46bd1a4497cc2 on gdomingu:rescue-json-parse into a711325ce1277f7d5bf856252793920d4a6b1879 on filestack:master.

gabifija commented 4 years ago

@gdomingu I've updated it in filestack-ruby 2.8.1. Thanks for your comments!