fix(web)!: retain capture read cleanup through export

BREAKING CHANGE: WebScriptExportError accepts error context and residual paths in an options object.
This commit is contained in:
morluto
2026-10-11 06:30:56 +08:00
parent 67966c69a5
commit 95a77b6e25
4 changed files with 479 additions and 85 deletions
+13 -4
View File
@@ -1,4 +1,5 @@
import { ArtifactOperationError } from "./artifactOperationError.js";
import type { AnalysisErrorOptions } from "./analysisErrorBase.js";
/** Publication failure retaining its input/output target and cleanup state. */
export class WebScriptExportError extends ArtifactOperationError {
@@ -10,11 +11,19 @@ export class WebScriptExportError extends ArtifactOperationError {
reason: ArtifactOperationError["reason"],
target: string,
diagnostic: string,
residualPaths: readonly string[] = [],
options: AnalysisErrorOptions & {
readonly residualPaths?: readonly string[];
} = {},
) {
super("export_web_scripts", reason);
super("export_web_scripts", reason, undefined, undefined, options);
this.userMessage = `Script export failed for ${target}: ${diagnostic}`;
this.cleanupResources = residualPaths;
this.cleanupIncomplete = residualPaths.length > 0;
this.cleanupResources = [
...new Set([
...(options.cleanup?.resources ?? []),
...(options.residualPaths ?? []),
]),
];
this.cleanupIncomplete =
options.cleanup !== undefined || (options.residualPaths?.length ?? 0) > 0;
}
}