mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
32 lines
1.0 KiB
TypeScript
32 lines
1.0 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,
|
|
...(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);
|