shiftcommerce / flex-ruby-gem

💎 The Ruby library used to integrate with the Shift Platform API
MIT License
2 stars 0 forks source link

Improve error messages thrown when json parsing fails #154

Closed hubertpompecki closed 6 years ago

hubertpompecki commented 6 years ago

Currently, when the gem fails to parse json received from the back-end it throws errors looking like the following:

JSON::ParserError: quoted string not terminated at line 1, column 13937 [parse.c:337]

The message above does not include the malformed payload and the payload is not included in server logs either because we don't have logging enabled for the front-end.

This PR extends the json_api_client gem on which the flex-rub-gem relies to include malformed json bodies as Sentry context in any JSON::ParserError errors it throws.

hubertpompecki commented 6 years ago

EDIT: I decided to use raven_context instead of the error message itself to avoid long and unreadable error messages. Whilst at it, I have also added raven_context to FlexCommerceApi::Error::InternalServer so that we have more visibility into all kinds of internal server errors as well.