fix(ui): add error state handling for core API calls - #705
Open
Saloni3494 wants to merge 1 commit into
Open
Conversation
Fixes: containers#595 Signed-off-by: Saloni Tanmor <saloni.tanmor1@gmail.com>
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.
What changed
errorstate to theuseBlogPostscustom hook to catch and expose API failures.fetchDatafunction to explicitly checkrawData.okso that HTTP error responses (like 404s or 429 Rate Limits) correctly throw and trigger the error state.BlogArticlesList/index.tsxto conditionally render a clean fallback UI ("Failed to load the latest blog posts. Please check back later.") if theerrorstate is truthy.Why this change is needed
Currently, the dynamic data fetch for the latest blog posts on the Homepage and Features page fails silently if there is a network issue or if the WordPress API is unreachable. This leaves the user with an incomplete page and no indication of what went wrong.
By handling these failure states and providing a fallback message, we improve the overall resilience of the UI and ensure the site doesn't feel broken during unexpected network/API disruptions. The fallback UI preserves the
SectionHeaderto maintain the existing layout structure without causing jarring layout shifts.Testing
yarn typecheckpassing logic is unaffected by the new hook return type.yarn buildsucceeds.Fixes: #595
Checklist
git commit -s). The author email must match the sign-off email address.Fixes: #00000in the commit message.