Skip to content

Improve error messages thrown when json parsing fails#154

Merged
hubertpompecki merged 4 commits intomasterfrom
improve-json-parser-error-logging
Oct 3, 2018
Merged

Improve error messages thrown when json parsing fails#154
hubertpompecki merged 4 commits intomasterfrom
improve-json-parser-error-logging

Conversation

@hubertpompecki
Copy link
Copy Markdown
Contributor

@hubertpompecki hubertpompecki commented Aug 7, 2018

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.

Copy link
Copy Markdown
Contributor

@RichardWatkins1 RichardWatkins1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hubertpompecki
Copy link
Copy Markdown
Contributor Author

hubertpompecki commented Aug 7, 2018

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.

@hubertpompecki hubertpompecki force-pushed the improve-json-parser-error-logging branch from 3b92e9c to 0409774 Compare August 7, 2018 14:31
@hubertpompecki hubertpompecki merged commit e64a65e into master Oct 3, 2018
@hubertpompecki hubertpompecki deleted the improve-json-parser-error-logging branch October 3, 2018 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants