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:
1 parent
ecd1bc2e33
commit
40040b3dd2
46 files changed
+209
-113
No files matched your search
@@ -139,7 +139,7 @@ export function createThreadIntegration({ db, logger, emitEvent, publishDomainCh
|
||||
});
|
||||
notifyThreadSubscribers(db, thread.id, thread.title, approvalReason, notify);
|
||||
}
|
||||
announceApprovalToBoard(db, approval, { emitEvent, publishDomainChanged });
|
||||
announceApprovalToBoard(db, approval, { emitEvent, publishDomainChanged, logger });
|
||||
} catch (err) {
|
||||
logger.error(`[thread-integration] onApprovalCreated failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
}
|
||||
@@ -305,7 +305,8 @@ export function createThreadIntegration({ db, logger, emitEvent, publishDomainCh
|
||||
try {
|
||||
const task = db.getTask(thread.relatedEntityId);
|
||||
if (task.assigneeAgentId !== toAgentId) continue;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-integration] getTask failed for thread ${ws.threadId}:`, err instanceof Error ? err.message : String(err));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +322,8 @@ export function createThreadIntegration({ db, logger, emitEvent, publishDomainCh
|
||||
try {
|
||||
const waitStates = db.listThreadWaitStates(companyId);
|
||||
return waitStates.length > 0;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-integration] hasUnresolvedWaitStates query failed for company ${companyId}:`, err instanceof Error ? err.message : String(err));
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@@ -343,7 +345,8 @@ export function createThreadIntegration({ db, logger, emitEvent, publishDomainCh
|
||||
companyId, agentId,
|
||||
);
|
||||
return rows.length > 0;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-integration] hasUnresolvedWaitStatesForAgent query failed (company=${companyId} agent=${agentId}):`, err instanceof Error ? err.message : String(err));
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@@ -355,7 +358,8 @@ export function createThreadIntegration({ db, logger, emitEvent, publishDomainCh
|
||||
countUnresolvedWaitStates(companyId: string): number {
|
||||
try {
|
||||
return db.listThreadWaitStates(companyId).length;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-integration] countUnresolvedWaitStates failed for company ${companyId}:`, err instanceof Error ? err.message : String(err));
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ThreadType } from "@shared/types";
|
||||
|
||||
export interface ThreadIntegrationDeps {
|
||||
db: AppDatabase;
|
||||
logger: { info: (...args: unknown[]) => void; error: (...args: unknown[]) => void };
|
||||
logger: { info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void };
|
||||
emitEvent?: (event: import("@shared/types").DesktopEvent) => void;
|
||||
publishDomainChanged?: () => void;
|
||||
notify?: (options: { title: string; body: string }) => void;
|
||||
@@ -64,6 +64,7 @@ function resolveApprovalAnnouncementChannel(
|
||||
companyId: string,
|
||||
taskId: string | null,
|
||||
requestedByAgentId: string | null,
|
||||
logger: ThreadIntegrationDeps["logger"],
|
||||
): { channel: "department" | "project" | "company"; channelTargetId: string | null } | null {
|
||||
if (requestedByAgentId) {
|
||||
try {
|
||||
@@ -71,8 +72,8 @@ function resolveApprovalAnnouncementChannel(
|
||||
if (requester.companyId === companyId && requester.department) {
|
||||
return { channel: "department", channelTargetId: requester.department };
|
||||
}
|
||||
} catch {
|
||||
// Fall through to task/project/company targeting.
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-helpers] getAgent failed for requester ${requestedByAgentId}; falling through to task targeting:`, err instanceof Error ? err.message : String(err));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,8 +83,8 @@ function resolveApprovalAnnouncementChannel(
|
||||
if (task.companyId === companyId && task.projectId) {
|
||||
return { channel: "project", channelTargetId: task.projectId };
|
||||
}
|
||||
} catch {
|
||||
// Fall through to company-wide routing.
|
||||
} catch (err) {
|
||||
logger.warn(`[thread-helpers] getTask failed for task ${taskId}; falling through to company routing:`, err instanceof Error ? err.message : String(err));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ export function announceApprovalToBoard(
|
||||
payloadSummary: string;
|
||||
impactSummary: string;
|
||||
},
|
||||
deps: Pick<ThreadIntegrationDeps, "emitEvent" | "publishDomainChanged">,
|
||||
deps: Pick<ThreadIntegrationDeps, "emitEvent" | "publishDomainChanged" | "logger">,
|
||||
): void {
|
||||
if (!approval.requestedByAgentId || !deps.emitEvent || !deps.publishDomainChanged) return;
|
||||
|
||||
@@ -109,6 +110,7 @@ export function announceApprovalToBoard(
|
||||
approval.companyId,
|
||||
approval.relatedTaskId,
|
||||
approval.requestedByAgentId,
|
||||
deps.logger,
|
||||
);
|
||||
if (!target) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user