Events API raises JSON::ParserError
when server responds with HTML error
#51
Labels
JSON::ParserError
when server responds with HTML error
#51
Hi! A few days ago, I observed the same error as described in #47, but with the Events API. I believe there was some instability on your end and my app received some HTML errors, and this gem raised
JSON::ParserError
.Expected Behavior
When RD Events API responds with an error, even if in HTML format, the gem should raise a semantic error, for instance
RDStation::Error::BadGateway
.Current Behavior
JSON::ParserError
is raised instead.Failure Information
Gem version
2.1.0
Sample trace
Solution
I can't be completely sure of the status code of the response, but the HTML body mentioned 502, so I'm assuming the status code was the same. I then checked the source of the Events API and it is not using the
ApiResponse
module, which is the one that was changed to check status codes before parsing as a fix for #47, so I think this is the cause:rdstation-ruby-client/lib/rdstation/events.rb
Lines 12 to 19 in fba83df
A possible fix is to change that to use
ApiResponse
like the other APIs, for instance Contacts:rdstation-ruby-client/lib/rdstation/contacts.rb
Lines 41 to 46 in fba83df
If that sounds good, I can open a pull request.
The text was updated successfully, but these errors were encountered: