refactor(errors): surface 57 deferred catch-and-swallow sites via logger

The earlier sweep cleaned the hot path (worker/runtime/automation/api-
server/ipc core — 59 sites). This pass finishes the deferred long tail:
main/* services, database/* CRUD modules, api-server/* routes, ipc-*
handlers, thread-integration, automation helpers, browser, skills.

Default strategy: catch (error) { logger.warn("[module] context:", ...) }
— preserve current behavior, make the failure visible instead of
silently hidden. Widened 3 logger interface signatures to include warn
where callers only passed info/error previously (thread-helpers,
host-environment-service, ipc-domain-common).

Legitimate boundaries left intact: JSON.parse on untrusted input, DNS
resolver no-records paths, explicit safe* helpers (safeJson, parseJson,
parseTriggerDetail), URL-parse predicates, and `<unserialisable>`
fallbacks inside the prompt-builder summarisers. Each kept catch now
either has a reason in context or is a documented safe* helper.

Tests adjusted only where test-constructed no-op loggers needed a warn
stub (message-dispatch, company-mode-switch, ipc-agent-graph-handlers).

With the earlier pass, AgentCompany no longer has silently-swallowing
catch blocks in main-process or renderer business code.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-17 15:25:13 -04:00
1 parent ecd1bc2e33
commit 40040b3dd2
46 files changed
+209 -113

No files matched your search

+14 -6
View File
@@ -20,6 +20,7 @@ export function registerCoreReadHandlers({
resetAfterRestore,
getApiPort,
listConnectorModels,
logger,
}: Pick<
RegisterCoreHandlersDependencies,
| "registerHandle"
@@ -30,6 +31,7 @@ export function registerCoreReadHandlers({
| "resetAfterRestore"
| "getApiPort"
| "listConnectorModels"
| "logger"
>) {
registerHandle(IPC_CHANNELS.loadSnapshot, () => ok(db.listRendererSnapshot()));
@@ -109,7 +111,8 @@ export function registerCoreReadHandlers({
try {
const parsed = connectorInputSchema.shape.id.parse(connectorId);
return ok(await listConnectorModels(parsed));
} catch {
} catch (err) {
logger.warn(`[ipc] listConnectorModels failed for connector ${String(connectorId)}:`, err instanceof Error ? err.message : String(err));
return ok([]);
}
});
@@ -118,7 +121,8 @@ export function registerCoreReadHandlers({
try {
const parsed = connectorInputSchema.shape.id.parse(connectorId);
return ok(db.getDisabledModels(parsed));
} catch {
} catch (err) {
logger.warn(`[ipc] getConnectorDisabledModels failed for connector ${String(connectorId)}:`, err instanceof Error ? err.message : String(err));
return ok([]);
}
});
@@ -180,7 +184,8 @@ export function registerCoreReadHandlers({
const task = db.getTask(parsed.id);
if (task.companyId !== parsed.companyId) return fail("TASK_NOT_FOUND", "Task not found in current company.");
return ok(task);
} catch {
} catch (err) {
logger.warn(`[ipc] getTask failed for id ${parsed.id}:`, err instanceof Error ? err.message : String(err));
return fail("TASK_NOT_FOUND", "Task not found.");
}
});
@@ -193,7 +198,8 @@ export function registerCoreReadHandlers({
const agent = db.getAgent(parsed.id);
if (agent.companyId !== parsed.companyId) return fail("AGENT_NOT_FOUND", "Agent not found in current company.");
return ok(agent);
} catch {
} catch (err) {
logger.warn(`[ipc] getAgent failed for id ${parsed.id}:`, err instanceof Error ? err.message : String(err));
return fail("AGENT_NOT_FOUND", "Agent not found.");
}
});
@@ -206,7 +212,8 @@ export function registerCoreReadHandlers({
const run = db.getRun(parsed.id);
if (run.companyId !== parsed.companyId) return fail("RUN_NOT_FOUND", "Run not found in current company.");
return ok(run);
} catch {
} catch (err) {
logger.warn(`[ipc] getRun failed for id ${parsed.id}:`, err instanceof Error ? err.message : String(err));
return fail("RUN_NOT_FOUND", "Run not found.");
}
});
@@ -219,7 +226,8 @@ export function registerCoreReadHandlers({
const approval = db.getApprovalRecord(parsed.id);
if (approval.companyId !== parsed.companyId) return fail("APPROVAL_NOT_FOUND", "Approval not found in current company.");
return ok(approval);
} catch {
} catch (err) {
logger.warn(`[ipc] getApprovalRecord failed for id ${parsed.id}:`, err instanceof Error ? err.message : String(err));
return fail("APPROVAL_NOT_FOUND", "Approval not found.");
}
});