Fix file size too large error and refactor API toast messaging#1202
Open
cj-young wants to merge 9 commits into
Open
Fix file size too large error and refactor API toast messaging#1202cj-young wants to merge 9 commits into
cj-young wants to merge 9 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1201.
Previously, the logic to display a toast notification was prop-drilled into each component that makes an API call, and a new API instance is created each time. Now, a single API object is used. Also, the logic for displaying a toast has been moved into the App component in the form of a new event listener on the API object.
A 413 option for the toast display function was added to add feedback on "File size too large" errors. Other error status toasts can easily be added later.
In the future, error display shouldn't rely just on status codes since very different errors might have the same status codes but completely different contexts and therefore different intended error messages. A more robust error handling method for API calls should be added. This includes abstracting away response handling (e.g. removing the middleman of
response.json()and checkingresponse.okon every call) and replacing it with API methods that either return the correct result or throw an error.