Improve frontend API error handling#494
Conversation
e1e2b38 to
8d15f10
Compare
There was a problem hiding this comment.
Pull request overview
This PR centralizes frontend API error/warning reporting by introducing a small logging helper that shows user-friendly toasts while still logging full errors to the browser console. It also refactors apiFetch / ApiError and updates multiple call sites to use the new logging approach.
Changes:
- Add
logApiError/logApiWarninghelper and replace variousconsole.error/showErrorToastFromusages across the UI. - Update
ApiError/backend error parsing and adjust related consumers (e.g. DirectoryPicker, ProjectLanding). - Tweak toast durations and clean up a handful of warning/toast messages.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/frontend/app/utils/logger.ts | Adds centralized toast+console logging helpers for API warnings/errors. |
| src/main/frontend/app/utils/api.ts | Refactors ApiError shape and apiFetch header/body handling and response parsing. |
| src/main/frontend/app/routes/studio/context/sorted-elements.tsx | Consolidates warning toast + console message for failed drop action. |
| src/main/frontend/app/routes/studio/canvas/flow.tsx | Uses logApiError for save/load flow failures. |
| src/main/frontend/app/routes/projectlanding/project-landing.tsx | Refactors app-info fetch flow and logs discovery errors via logApiError. |
| src/main/frontend/app/routes/editor/editor.tsx | Switches save/load/reformat error handling to logApiError. |
| src/main/frontend/app/routes/datamapper/root.tsx | Minor console + toast message cleanup for debug button. |
| src/main/frontend/app/routes/datamapper/property-list.tsx | Comment/message cleanup and minor refactors for readability. |
| src/main/frontend/app/providers/frankconfig-xsd-provider.tsx | Uses logApiWarning when XSD fetch fails. |
| src/main/frontend/app/components/toast.tsx | Adjusts default toast durations; removes showErrorToastFrom. |
| src/main/frontend/app/components/git/git-panel.tsx | Switches git API failure handling to logApiError. |
| src/main/frontend/app/components/file-structure/use-studio-context-menu.ts | Switches context menu error handling to logApiError. |
| src/main/frontend/app/components/file-structure/use-file-tree-context-menu.ts | Switches context menu error handling to logApiError. |
| src/main/frontend/app/components/file-structure/studio-files-data-provider.ts | Uses logApiError when loading directories fails; simplifies warn messages. |
| src/main/frontend/app/components/file-structure/editor-data-provider.ts | Uses logApiWarning for file tree/directory load failures; simplifies warn messages. |
| src/main/frontend/app/components/directory-picker/directory-picker.tsx | Updates forbidden-access handling to use ApiError.httpCode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ervices # Conflicts: # src/main/frontend/app/components/file-structure/studio-files-data-provider.ts
stijnpotters1
left a comment
There was a problem hiding this comment.
'logApiWarning' is defined but never used. Allowed unused vars must match
in 'src/main/frontend/app/components/file-structure/editor-data-provider.ts'
|



Toasts based on API errors/warnings are now more user friendly while outputting the stacktrace to the browser console
Tiny cleanup where I found improvements to be made