Files
rea/src/artifacts/SafeOutputTreeCreationFailure.ts
T
morluto 542fa84957 fix(artifacts): retain descriptor ownership and read completion facts
Refs #4458, #4483.

Own admitted descriptors through final close, retain exact failed owners, and preserve physical read failures and cancellation reasons. Track stream coverage independently from delivered bytes and share the boundary across archive, Mach-O, hashing, and output readback consumers.
2026-10-17 00:44:02 +08:00

33 lines
1.1 KiB
TypeScript

import { ArtifactReaderFailure } from "./ArtifactReader.js";
import type { SafeOutputTree } from "./SafeOutputTree.js";
/** Setup failed after this tree was acquired; callers still own this exact tree. */
export class SafeOutputTreeCreationFailure extends ArtifactReaderFailure {
readonly tree: SafeOutputTree;
constructor(cause: unknown, tree: SafeOutputTree) {
const primary =
cause instanceof ArtifactReaderFailure
? cause
: new ArtifactReaderFailure("io", errorMessage(cause), { cause });
super(
primary.reason,
primary.message,
{
cause: primary,
cancellation: primary.cancellation,
...(primary.cleanup === undefined ? {} : { cleanup: primary.cleanup }),
...(primary.partialObservation === undefined
? {}
: { partialObservation: primary.partialObservation }),
},
primary.details,
);
this.name = "SafeOutputTreeCreationFailure";
this.tree = tree;
}
}
const errorMessage = (cause: unknown): string =>
cause instanceof Error ? cause.message : String(cause);