Skip to content

Improve frontend API error handling#494

Merged
Matthbo merged 8 commits into
masterfrom
issue/479-frontend-error-handling-of-api-services
May 27, 2026
Merged

Improve frontend API error handling#494
Matthbo merged 8 commits into
masterfrom
issue/479-frontend-error-handling-of-api-services

Conversation

@Matthbo

@Matthbo Matthbo commented May 22, 2026

Copy link
Copy Markdown
Member

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

@Matthbo Matthbo force-pushed the issue/479-frontend-error-handling-of-api-services branch from e1e2b38 to 8d15f10 Compare May 22, 2026 15:04
@Matthbo Matthbo requested review from Copilot and stijnpotters1 May 22, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / logApiWarning helper and replace various console.error / showErrorToastFrom usages 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.

Comment thread src/main/frontend/app/utils/api.ts Outdated
Comment thread src/main/frontend/app/utils/api.ts Outdated
Comment thread src/main/frontend/app/routes/studio/canvas/flow.tsx Outdated
Comment thread src/main/frontend/app/routes/studio/canvas/flow.tsx
Comment thread src/main/frontend/app/providers/frankconfig-xsd-provider.tsx
@stijnpotters1 stijnpotters1 linked an issue May 26, 2026 that may be closed by this pull request
Comment thread src/main/frontend/app/routes/editor/editor.tsx
Comment thread src/main/frontend/app/components/file-structure/editor-data-provider.ts Outdated
Comment thread src/main/frontend/app/components/file-structure/editor-data-provider.ts Outdated
@Matthbo Matthbo requested a review from stijnpotters1 May 27, 2026 08:50

@stijnpotters1 stijnpotters1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'logApiWarning' is defined but never used. Allowed unused vars must match
in '‎src/main/frontend/app/components/file-structure/editor-data-provider.ts'

@Matthbo Matthbo requested a review from stijnpotters1 May 27, 2026 12:27
@sonarqubecloud

Copy link
Copy Markdown

@Matthbo Matthbo merged commit 2458cd1 into master May 27, 2026
5 of 6 checks passed
@Matthbo Matthbo deleted the issue/479-frontend-error-handling-of-api-services branch May 27, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend error handling of API services

3 participants