You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(ui): name the failure policy instead of an empty catch
The 21 empty catch blocks each carried a sentence saying why an error was
swallowed. Under the allowlist that sentence is allowed to stay — the body of
an empty block is one of the four kinds of comment the rule keeps — but the
comment was never the best form for it. None of these needed a comment. They
needed a name.
utils/failure.ts holds four, each documented with when it is the right one:
ignoreFailure and nullOnFailure for .catch(), attempt for a synchronous call
that may not be there at all, and succeeded for a call whose error is already
recorded somewhere the screen reads.
Most sites did not even need those. The failure had an answer the code was not
stating: parseMessage returns null, because a frame that is not JSON is
ordinary terminal output; loadConfig falls back in the expression, so the
default is visible in the data flow; markWelcomeSeen returns whether it stuck,
mirroring hasSeenWelcome; listRecordings reads each sidecar through a helper
returning RecordingMeta | null, so a corrupt one is skipped by an if; and four
react-query call sites used mutateAsync inside a try that discarded the
rejection, where mutate() reports through the mutation's own state.
ForgotPassword keeps its reason in the code, as a name:
const silenceToPreventAccountEnumeration = ignoreFailure;
await recoverPassword({ ... }).catch(silenceToPreventAccountEnumeration);
Two behaviours are better than before rather than merely equivalent: Chatwoot
records the identity only when setUser actually succeeded, and the settings
toggles clear their busy flag through onSettled instead of a finally that ran
whether or not the mutation was still relevant.
This is the same change as on the total-ban branch, where it removes 21 lint
suppressions. Here it removes 21 comments the rule would have allowed, which
is the more interesting result: the allowance was carrying code that wanted
rewriting.
0 commit comments