voucherifyio / voucherify-ruby-sdk

Ruby SDK for Voucherify - coupons, vouchers, promo codes
http://www.voucherify.io
MIT License
9 stars 12 forks source link

Support blank API response in exception handling #59

Open HyperDanTabist opened 10 months ago

HyperDanTabist commented 10 months ago

I've received a few errors originating from this line https://github.com/voucherifyio/voucherify-ruby-sdk/blob/master/lib/voucherify/client.rb#L145

unexpected token at ''
/usr/local/bundle/gems/json-2.6.3/lib/json/common.rb:216:in `parse',
/usr/local/bundle/gems/json-2.6.3/lib/json/common.rb:216:in `parse',
/usr/local/bundle/gems/voucherify-4.1.0/lib/voucherify/client.rb:145:in `initialize',
/usr/local/bundle/gems/voucherify-4.1.0/lib/voucherify/client.rb:93:in `new',
...

It appears that the error response is empty and the client cannot handle empty error responses. I've not be able to discover what is causing the empty error response. I can't find the request in the Voucherify API audit logs, so I suspect the request doesn't reach Voucherify. But it will help if the client can gracefully handle errors with empty responses.