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

+10 -6
View File
@@ -272,8 +272,8 @@ export function createSkillImporter({ db, profileDir: _profileDir, logger, skill
const pathParts = urlObj.pathname.split("/").filter(Boolean);
const lastPart = pathParts[pathParts.length - 1] ?? "";
urlSlug = normalizeSkillSlug(lastPart.replace(/\.md$/i, ""));
} catch {
// ignore URL parsing errors
} catch (err) {
logger.warn(`[skill-import] Unable to parse skill URL for slug derivation (${url}):`, err instanceof Error ? err.message : String(err));
}
const rawSlug =
normalizeSkillSlug(parsed.frontmatter.slug as string | undefined) ??
@@ -340,7 +340,8 @@ export function createSkillImporter({ db, profileDir: _profileDir, logger, skill
let realDir: string;
try {
realDir = realpathSync(dir);
} catch {
} catch (err) {
logger.warn(`[skill-import] realpathSync failed for ${dir}:`, err instanceof Error ? err.message : String(err));
return;
}
if (visitedRealPaths.has(realDir)) {
@@ -351,7 +352,8 @@ export function createSkillImporter({ db, profileDir: _profileDir, logger, skill
let entries: Dirent[];
try {
entries = readdirSync(dir, { withFileTypes: true });
} catch {
} catch (err) {
logger.warn(`[skill-import] readdirSync failed for ${dir}:`, err instanceof Error ? err.message : String(err));
return;
}
for (const entry of entries) {
@@ -395,7 +397,8 @@ export function createSkillImporter({ db, profileDir: _profileDir, logger, skill
let realDir: string;
try {
realDir = realpathSync(dir);
} catch {
} catch (err) {
logger.warn(`[skill-import] realpathSync failed for ${dir}:`, err instanceof Error ? err.message : String(err));
return;
}
if (visitedRealPaths.has(realDir)) {
@@ -406,7 +409,8 @@ export function createSkillImporter({ db, profileDir: _profileDir, logger, skill
let entries: Dirent[];
try {
entries = readdirSync(dir, { withFileTypes: true });
} catch {
} catch (err) {
logger.warn(`[skill-import] readdirSync failed for ${dir}:`, err instanceof Error ? err.message : String(err));
return;
}
for (const entry of entries) {