jlcodes99/cockpit-tools · error

message

Error message

message

What it means

A local-access health action in the Codex accounts controller (e.g. restoring account state) failed, and the resulting user-facing failure message is re-thrown as a generic Error via `throw new Error(message)`. The thrown value carries no error code; the message text is the localized status message that was also pushed to the toast/dialog. It signals that the requested local-access operation did not complete and callers (usually the `localAccessController` wrapper) must handle the rejection.

Source

Thrown at src/pages/useCodexAccountsLocalAccessController.tsx:927

            text: t("codex.localAccess.accountPoolHealth.recoverSuccess", {
              count: accountIds.length,
              defaultValue: "已提交 {{count}} 个账号的恢复操作",
            }),
          });
        } catch (error) {
          console.error("Failed to recover local access accounts:", error);
          const message = String(error).replace(/^Error:\s*/, "");
          setMessage({
            text: t("messages.actionFailed", {
              action: t(
                "codex.localAccess.accountPoolHealth.recover",
                "恢复账号状态",
              ),
              error: message,
            }),
            tone: "error",
          });
          throw new Error(message);
        } finally {
          setLocalAccessHealthActionBusy(false);
        }
      },
      [localAccessHealthActionBusy, setMessage, t],
    );
  
    const confirmHideLocalAccessEntry = useCallback(async () => {
      if (localAccessHideSubmitting) return;
      setLocalAccessHideSubmitting(true);
      try {
        if (localAccessCollection?.enabled) {
          const nextState =
            await codexLocalAccessService.setCodexLocalAccessEnabled(false);
          setLocalAccessState(nextState);
        }
        await invoke("set_codex_local_access_entry_visible", { enabled: false });
        setLocalAccessEntryVisible(false);

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Read the `message` shown in the error toast next to "恢复账号状态" — it contains the backend's actual failure reason.
  2. Re-run the local-access health check and retry the restore action once the previous operation has fully settled (busy flag reset).
  3. Re-import a healthy Codex account for the current environment if the account state cannot be restored.
  4. If it persists, inspect backend logs for the local-access command invocation that returned the failure.

Example fix

// before
catch (err) {
  setMessage({ text: err.message, tone: "error" });
  throw err;
}
// after
catch (err) {
  setMessage({ text: t("codex.localAccess.restoreFailed", "恢复账号状态失败"), tone: "error" });
  console.warn("local access restore failed", err);
  throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (localAccessHealthActionBusy) return; // never start while a previous action is in flight

Type guard

function isLocalAccessError(err: unknown): err is Error & { message: string } {
  return err instanceof Error && typeof err.message === "string" && err.message.length > 0;
}

Try / catch

try {
  await localAccessController("restore");
} catch (err) {
  if (err instanceof Error) {
    setMessage({ text: err.message, tone: "error" });
  } else {
    setMessage({ text: t("codex.localAccess.unknownError"), tone: "error" });
  }
}

Prevention

When it happens

Trigger: Calling a local-access health action (like "恢复账号状态" / restore account state) through the `localAccessController` callback while `localAccessHealthActionBusy` is false but the underlying action rejects or returns a failure message; the catch path sets an error toast with the message and then re-throws it.

Common situations: A Codex account is in an inconsistent state that the restore action cannot fix; the Tauri backend command returns an error string; the user double-triggers an action and a stale busy/health state causes the operation to abort with a message.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/16c43fb5f6e19824. Report an issue: GitHub.