mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { ProviderAdapterError } from "./providerAdapterError.js";
|
|
import { projectAnalysisError } from "./analysisErrorProjection.js";
|
|
import type { AnalysisError } from "./analysisErrorBase.js";
|
|
|
|
/** Preserve the original lifecycle failure alongside incomplete cleanup. */
|
|
export const analysisErrorWithCleanupFailure = (
|
|
primary: AnalysisError,
|
|
cleanup: AnalysisError,
|
|
operation = "close_binary",
|
|
): AnalysisError => {
|
|
const projected = projectAnalysisError(cleanup);
|
|
return new ProviderAdapterError(
|
|
cleanup instanceof ProviderAdapterError ? cleanup.providerId : "rea",
|
|
operation,
|
|
{
|
|
cause: primary,
|
|
userMessage: projectAnalysisError(primary).message,
|
|
...(primary.capturedOutput === undefined
|
|
? {}
|
|
: { capturedOutput: primary.capturedOutput }),
|
|
...(primary.partialObservation === undefined
|
|
? {}
|
|
: { partialObservation: primary.partialObservation }),
|
|
cleanup: {
|
|
reason: projected.message,
|
|
resources: [
|
|
...new Set([
|
|
...primary.cleanupResources,
|
|
...cleanup.cleanupResources,
|
|
]),
|
|
],
|
|
},
|
|
diagnostics: {
|
|
primary_error: projectAnalysisError(primary),
|
|
cleanup_error: projected,
|
|
},
|
|
},
|
|
);
|
|
};
|