refactor(runtime): name all silent catch causes without changing diagnostics (#637)

* refactor(domain): split error taxonomy into thematic modules

Move each error family out of domain/errors.ts into its own module
(base, core, provider selection/adapter, browser observation,
artifact, evidence, unknown registry, hopper, configuration) and
relocate AnalysisErrorProjection to analysisErrorProjection.
Migrate all 162 importers to the owning modules and delete
errors.ts. No re-export shims; behavior is unchanged.

* refactor(runtime): name all silent catch causes without changing diagnostics

Bind cause in every bare catch and unhandled rejection across src/.
Real failures preserve the cause for logging; best-effort cleanup
carries an explicit comment. Caller-visible and Evidence strings are
byte-identical to before.
This commit is contained in:
morluto
2026-10-06 05:58:46 +08:00
committed by GitHub
parent 735c10059c
commit 5f27e02fae
65 changed files with 363 additions and 131 deletions
+3 -1
View File
@@ -449,7 +449,9 @@ const processIsRunning = async (executablePath: string): Promise<boolean> => {
return processes.stdout
.split("\n")
.some((command) => command.trim() === executablePath);
} catch {
} catch (cause: unknown) {
// best-effort cleanup: optional process probing; failure means not running.
void cause;
return false;
}
};
+3 -1
View File
@@ -125,7 +125,9 @@ const sha256File = async (
return signalIsAborted(signal)
? err(new AnalysisCancelledError("open_binary"))
: ok(hash.digest("hex"));
} catch {
} catch (cause: unknown) {
// best-effort cleanup: unreadable targets mean no digest; abort still cancels.
void cause;
return signalIsAborted(signal)
? err(new AnalysisCancelledError("open_binary"))
: ok(undefined);
+2 -1
View File
@@ -166,8 +166,9 @@ const stopProcess = async (
);
try {
input.onDiagnostic?.(diagnostic);
} catch {
} catch (cause: unknown) {
// Diagnostic consumers cannot change the already-observed cleanup result.
void cause;
}
input.logger.info(diagnostic, "Owned Hopper launcher shutdown completed");
if (stopped.status !== "incomplete") {
+6 -2
View File
@@ -397,7 +397,9 @@ export class HopperClient {
);
try {
await access(socketPath);
} catch {
} catch (cause: unknown) {
// best-effort cleanup: socket polling; absence means keep waiting.
void cause;
if ((await deadline.wait(50)) === "aborted")
return err(startupInterruption(deadline));
continue;
@@ -476,7 +478,9 @@ export class HopperClient {
category: message.event.error.type,
message: message.event.error.message,
});
} catch {
} catch (cause: unknown) {
// best-effort cleanup: diagnostic consumers must not break the client.
void cause;
this.#logger.warn(
{ requestId: message.id },
"Hopper bridge diagnostic consumer rejected an event",
+3 -1
View File
@@ -124,7 +124,9 @@ export class HopperProvider implements AnalysisProviderCandidate {
reason: null,
diagnostics,
};
} catch {
} catch (cause: unknown) {
// best-effort cleanup: optional launcher probing; failure means unavailable.
void cause;
return {
status: "unavailable",
code: "executable_missing",
+6 -2
View File
@@ -274,10 +274,14 @@ export class HopperRequestQueue {
#reportUpdate(entry: QueuedRequest, update: ProgressUpdate): void {
try {
void Promise.resolve(entry.progress?.report(update)).catch(
() => undefined,
(cause: unknown) => {
// best-effort cleanup: progress rejection bookkeeping only.
void cause;
},
);
} catch {
} catch (cause: unknown) {
// Progress observation cannot change the request outcome.
void cause;
}
}
}
+6 -2
View File
@@ -112,7 +112,9 @@ export const runLinuxPrivateDisplayProbe: LinuxPrivateDisplayProbeRunner =
runId: randomUUID(),
expectedCommand: null,
});
} catch {
} catch (cause: unknown) {
// best-effort cleanup: probe spawn failure is reported as launch-failed.
void cause;
return emptyProcessResult("launch-failed");
}
const launch: ProviderProcessLaunch = {
@@ -198,7 +200,9 @@ const evaluatedProbe = async (
timeoutMs,
...(options.signal === undefined ? {} : { signal: options.signal }),
});
} catch {
} catch (cause: unknown) {
// Runner failure is reported with the synthetic probe_failed diagnostic.
void cause;
return {
ok: false,
diagnostic: syntheticDiagnostic(strategy, "probe_failed"),