taxjar / taxjar-ruby

Sales Tax API Client for Ruby
https://developers.taxjar.com/api/reference/?ruby
MIT License
54 stars 40 forks source link

Add better error handling for non-JSON responses #51

Closed yjukaku closed 5 years ago

yjukaku commented 5 years ago

This closes #50 by asking the HTTP library to explicitly parse the response as JSON. If that fails, we get a specific error type, JSON::ParserError. We then turn that into a Taxjar::Error::ServerError.

In some cases, the TaxJar API is returning HTML with the Content-Type text/html and that causes this library to fail with a generic error from the http-ruby library. With this change, we will have a specific error that is namespaced by Taxjar.

yjukaku commented 5 years ago

👋 I made the changes as requested - any chance of this getting merged and released soon? 😁

ScottRudiger commented 5 years ago

Thanks for contributing @yjukaku! This LGTM after your changes. 👍

@prsimp Any further concerns?

yjukaku commented 5 years ago

❤️ Awesome, thanks all! Looking forward to the release. 🚀