Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer API Failure Errors #1633

Merged
merged 2 commits into from
Sep 10, 2020
Merged

Nicer API Failure Errors #1633

merged 2 commits into from
Sep 10, 2020

Conversation

mariusandra
Copy link
Collaborator

Changes

This PR add a little bit more information for the case when we are unable to parse the JSON from the server.

Before:
2020-09-10 13 32 07

After:
2020-09-10 13 31 20

I also converted api.js to use async/await.

This could obviously be further improved.

Checklist

  • All querysets/queries filter by Team (if this PR affects any querysets/queries)
  • Backend tests (if this PR affects the backend)
  • Cypress E2E tests (if this PR affects the front and/or backend)

@mariusandra mariusandra requested a review from Twixes September 10, 2020 11:37
@timgl timgl temporarily deployed to posthog-nicer-api-error-f6acc2 September 10, 2020 11:38 Inactive
@mariusandra mariusandra marked this pull request as draft September 10, 2020 11:50
@mariusandra
Copy link
Collaborator Author

Something's broken in the Cypress tests. Converting to draft and will check later.

@mariusandra mariusandra marked this pull request as ready for review September 10, 2020 12:21
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Looks good! As for possible improvements, getJSONOrThrow could also implement !response.ok handling.

@mariusandra mariusandra merged commit bfd856b into master Sep 10, 2020
@mariusandra mariusandra deleted the nicer-api-errors branch September 10, 2020 14:32
@mariusandra
Copy link
Collaborator Author

Definitely re: response.ok! I didn't want to change the behaviour now though. It could be revisited when we get the backend to send consistent JSON responses for errors.

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.

3 participants