fix: deduplicate error handling between global handler and page-level catch - #258
Open
hashbk wants to merge 1 commit into
Open
fix: deduplicate error handling between global handler and page-level catch#258hashbk wants to merge 1 commit into
hashbk wants to merge 1 commit into
Conversation
… 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
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
errorHandler(requestErrorConfig.ts) and page-leveltry/catchblocks showingmessage.errorfor the same request failureskipErrorHandler: trueto all mutation service functions (POST/PUT/PATCH/DELETE) so pages that already handle errors viatry/catch+msgApi.errorskip the global handler{ skipErrorHandler: true }at call sites for GET requests wrapped intry/catch(e.g.getStrategy,getOidcProvider,getGeneralSettings,getPermissionList,getConnectionAuditsin CSV export, option loaders inAssignModal/EditDeviceModal)request(no surroundingtry/catch) retain global error handling — no behavior changeskipErrorHandlerusers (auth.login,passkey.*Begin,smtp.getSMTPConfig,ldap.getLdapConfig,nexus.*,settings.getFrontendSettings) are all correctly handled in their respective pagesRoot Cause
requestErrorConfig.tsline 38 checksopts?.skipErrorHandler— when unset, the global handler showsmessage.error. Most mutation services did not set this flag, so when a page wrapped the call intry { ... } catch { msgApi.error(...) }, the user saw two error messages.Changes
Service layer (16 files): Added
skipErrorHandler: trueto all mutation functions. Addedoptionsparameter 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 insidetry/catchblocks (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: truein mutation request configs.Verification
tsc --noEmit— passbiome lint— no new warnings (pre-existing only)jest— 10/10 pass