feat(webui): improve API error handling with structured toast notifications#210
Open
brancan wants to merge 1 commit intohnimminh:masterfrom
Open
feat(webui): improve API error handling with structured toast notifications#210brancan wants to merge 1 commit intohnimminh:masterfrom
brancan wants to merge 1 commit intohnimminh:masterfrom
Conversation
…ions - Add ShowAPIError function for better error display - Enhance ShowToast with adaptive duration and HTML support - Add protection against undefined array forEach errors - Improve CSS styling for error messages - Support Pydantic validation errors with structured display This improves user experience by showing clear, structured error messages instead of basic console errors, making debugging easier for users.
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.
Summary
This PR improves the WebUI's API error handling by adding a structured error display system on top of the existing toast notification component.
Changes
ShowAPIError(jqXHR, fallback)helper that parses common errorshapes returned by the API (string, plain
{detail}, Pydantic-style[{loc, msg, type}]) and renders them in a readable, multi-line toast.ShowToastwith:visible longer instead of vanishing too quickly).
forEachcalls when responses aremalformed.
customize.cssfor compact, readable error toasts(color-coded, monospace for codes/paths, line-broken for long messages).
Why
Today, when the API returns a Pydantic validation error or a structured
HTTP error, the WebUI either shows a generic message or dumps the raw
object to the console. End users have no signal of what's wrong, and
operators have to open the browser devtools.
This PR keeps the existing
ShowToastAPI (no breaking change) and addsa richer overlay path that:
Backward compatibility
ShowToast(message)callers.Test plan
to
/libreapi/predefine/codec/{name}) and verify the new toastshows
loc,msgandtypeclearly.{detail: "..."}error and verify the toast shows thedetail string.
Cherry-picked from a downstream deployment of LibreSBC where this
patch has been running in production for several months. Original
commit:
82a0f62.