Fix frontend axios error handling#6467
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized getErrorMessage utility to extract error messages from Axios responses and standard errors, replacing inline error-parsing logic in ToolDialog.jsx and adding corresponding unit tests. The review feedback suggests improving the utility by handling cases where the response message is an array of strings (e.g., validation errors from NestJS) and joining them, ensuring detailed error messages are not lost.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Hii Maintainers....please review this PR and tell me any changes if needed...! |
Standardize ToolDialog error handling with shared Axios-safe error extractor
Linked issue
Closes #6466
Description
This PR improves frontend API error handling by making the shared
getErrorMessageutility safer for Axios-style errors and using it inToolDialog.Previously,
ToolDialogdirectly accessederror.response.datainside several catch blocks. That can fail when Axios does not include aresponseobject, such as during network failures, backend downtime, CORS issues, timeouts, or cancelled requests. In those cases, the error handler could throw another runtime error while trying to display the original API failure.Changes made
Updated
packages/ui/src/utils/errorHandler.jsresponse.data.messageresponse.data.errorUpdated
packages/ui/src/views/tools/ToolDialog.jsxerror.response.dataaccess withgetErrorMessage(error)Added
packages/ui/src/utils/errorHandler.test.jserrorfieldsWhy this is needed
Instead of each component manually reading nested Axios fields, the shared helper now handles the common API error shapes safely. Components can show useful error messages without risking a secondary crash inside the catch block.
Testing
Ran the focused UI test:
pnpm -C packages/ui test errorHandler.test.js --runInBandResult:
Screenshots
Not applicable. This is an error-handling utility change and does not alter the normal UI layout.
Additional notes
This PR keeps the scope focused on
ToolDialogand the shared error extractor. Other frontend components still contain similar inline Axios error parsing and can be migrated in follow-up PRs.