Add graceful fallback response for API calls #328
Merged
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.
Description
This PR adds an explicit fallback response to avoid page crashing errors on failed API requests, such that the app can handle them more gracefully. For the
main
API route, the previous behaviour remains for compatibility.Development notes
An example use case is to avoid page crashes when loading JSON files in place of a real API, without needing to export all of the files for each possible API request. In practice this then allows the metadata panel to be used with a single
main
JSON file for testing while falling back gracefully for missing data.All request errors are still visible in the console logs as normal, we could potentially add more information through an additional
console.error
if needed. Later on if needed, we could also add anerror
flag to the fallback response.We could also consider extending this behaviour to the
main
route too, but for now it remains a special case to retain the previous behaviour (an informative error), avoiding this being a breaking change for that route.QA notes
Using a
public/main
JSON test file, test all features that use API requests (first load, pipeline select, metadata panel).Checklist
RELEASE.md
fileLegal notice
I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":
I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.
I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.