refactor(errors): defer mutation errors to global handler

Now that MutationCache toasts via toUserMessage by default, the per-hook
onError duplicates drop away. Also normalizes inline query-error UI and
surfaces a previously-silent failure.

Mutations — removed redundant onError toasts:
- network-selector: useAcceptInvitation, createNetwork (inline)
- network-settings: useInviteMembers, useRevokeInvitation, useRemoveMember
- network-billing: useCreateCheckoutSession, useCreatePortalSession
  (onSuccess toasts stay — they carry domain context like network name)

Queries — consistent inline error UX via toUserMessage:
- network-selector: failed-to-load state gets a "Try again" button
- network-billing: "Couldn't load billing" includes friendly reason
- network-settings: useNetworkInvitations failure now surfaces a hint
  (previously rendered as "0 pending" — silently wrong)

Trimmed noisy JSDoc from PR 1 files (errors.ts, query-client.ts,
app-error-boundary.tsx, error-fallback.tsx, ipc-utils.ts).
This commit is contained in:
Claude
2026-04-17 02:52:45 +00:00
parent c00a7a439a
commit 8632c98725
8 changed files with 29 additions and 70 deletions
+9 -10
View File
@@ -79,9 +79,6 @@ function InviteForm({ networkId }: { networkId: string }) {
toast.success(`Invitation sent to ${trimmed}`);
setEmail("");
},
onError: (err) => {
toast.error(err.message || "Failed to send invitation");
},
});
};
@@ -119,9 +116,6 @@ function PendingInvitationRow({
onSuccess: () => {
toast.success(`Invitation to ${email} revoked`);
},
onError: (err) => {
toast.error(err.message || "Failed to revoke invitation");
},
});
};
@@ -188,7 +182,7 @@ export default function NetworkSettingsPage() {
const [searchParams] = useSearchParams();
const { data: networks } = useNetworks();
const network = networks?.find((n) => n.id === networkId);
const { data: invitations } = useNetworkInvitations(networkId!);
const { data: invitations, error: invitationsError } = useNetworkInvitations(networkId!);
const currentUser = useAuthStore((s) => s.user);
const isAdmin = currentUser?.id === network?.admin_human.id;
const [memberToRemove, setMemberToRemove] = useState<Human | null>(null);
@@ -286,6 +280,14 @@ export default function NetworkSettingsPage() {
/>
<Separator />
<InviteForm networkId={networkId!} />
{invitationsError && (
<>
<Separator />
<p className="text-muted-foreground px-4 py-3 text-xs">
Couldn't load pending invitations.
</p>
</>
)}
{pendingCount > 0 && (
<>
<Separator />
@@ -354,9 +356,6 @@ export default function NetworkSettingsPage() {
toast.success(`Removed ${target.email}`);
setMemberToRemove(null);
},
onError: (err) => {
toast.error(err.message || "Failed to remove member");
},
});
}}
onClose={() => {