Skip to content

fix: deduplicate error handling between global handler and page-level catch - #258

Open
hashbk wants to merge 1 commit into
mainfrom
fix/deduplicate-error-handling
Open

fix: deduplicate error handling between global handler and page-level catch#258
hashbk wants to merge 1 commit into
mainfrom
fix/deduplicate-error-handling

Conversation

@hashbk

@hashbk hashbk commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Eliminate double error toasts caused by both the global errorHandler (requestErrorConfig.ts) and page-level try/catch blocks showing message.error for the same request failure
  • Add skipErrorHandler: true to all mutation service functions (POST/PUT/PATCH/DELETE) so pages that already handle errors via try/catch + msgApi.error skip the global handler
  • Pass { skipErrorHandler: true } at call sites for GET requests wrapped in try/catch (e.g. getStrategy, getOidcProvider, getGeneralSettings, getPermissionList, getConnectionAudits in CSV export, option loaders in AssignModal/EditDeviceModal)
  • GET requests used solely by ProTable request (no surrounding try/catch) retain global error handling — no behavior change
  • Verified existing skipErrorHandler users (auth.login, passkey.*Begin, smtp.getSMTPConfig, ldap.getLdapConfig, nexus.*, settings.getFrontendSettings) are all correctly handled in their respective pages

Root Cause

requestErrorConfig.ts line 38 checks opts?.skipErrorHandler — when unset, the global handler shows message.error. Most mutation services did not set this flag, so when a page wrapped the call in try { ... } catch { msgApi.error(...) }, the user saw two error messages.

Changes

Service layer (16 files): Added skipErrorHandler: true to all mutation functions. Added options parameter to GET functions (getStrategy, getStrategyAssignments, getPersonalAddressBook, getCustomAddressBooks, getAllCustomAddressBooks, getLoginOptions) for call-site opt-in.

Page layer (8 files): Pass { skipErrorHandler: true } at GET call sites inside try/catch blocks (EditDeviceModal.fetchOptions, AssignModal.loadAssignedTargets/loadOptions, oidc-providers.fetchData/handleEdit, settings/general.useEffect, roles.fetchPermissions, address-book.loadAddressBooks, useCsvExport.fetchExportData, strategy.handleEdit).

Tests (2 files): Updated assertions to expect skipErrorHandler: true in mutation request configs.

Verification

  • tsc --noEmit — pass
  • biome lint — no new warnings (pre-existing only)
  • jest — 10/10 pass

… catch

Mutation service calls (POST/PUT/PATCH/DELETE) now set skipErrorHandler
to skip the global error handler when pages already handle errors via
try/catch with user-facing messages. GET requests wrapped in try/catch
also pass skipErrorHandler at call sites. This eliminates double error
toasts (global message.error plus page msgApi.error).

- Add skipErrorHandler to all mutation service functions
- Add options parameter to GET service functions used in try/catch
- Pass skipErrorHandler at page call sites for GET-in-try/catch cases
- Update test assertions to match new skipErrorHandler flag
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.

1 participant