mirror of
https://github.com/morluto/rea.git
synced 2026-11-24 13:18:39 +00:00
refactor(python): report pyc format failures through ParseFailure (#10664)
This commit is contained in:
1 parent
51e9dc156f
commit
b33e5c4867
5 files changed
+39
-65
No files matched your search
@@ -19,21 +19,15 @@ import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
|
||||
import type { PythonPycPort } from "../application/python/PythonPycPort.js";
|
||||
import type { ExecutionOptions } from "../application/AnalysisProvider.js";
|
||||
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import {
|
||||
AnalysisInputError,
|
||||
AnalysisResourceConstraintError,
|
||||
AnalysisUnsupportedTargetError,
|
||||
} from "../domain/analysisErrorCore.js";
|
||||
import { AnalysisResourceConstraintError } from "../domain/analysisErrorCore.js";
|
||||
import {
|
||||
PYTHON_PYC_LIMIT_MAXIMA,
|
||||
type InspectPythonPycInput,
|
||||
} from "../domain/python/pythonPyc.js";
|
||||
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
||||
import { err, ok } from "../domain/result.js";
|
||||
import {
|
||||
PythonPycFormatFailure,
|
||||
PythonPycResourceFailure,
|
||||
} from "./PythonPyc.errors.js";
|
||||
import { PythonPycResourceFailure } from "./PythonPyc.errors.js";
|
||||
import { parseFailureAnalysisError } from "../domain/parseFailureAnalysisError.js";
|
||||
import { parsePythonPyc } from "./PythonPycParser.js";
|
||||
|
||||
const OPERATION = "inspect_python_pyc";
|
||||
@@ -83,21 +77,8 @@ const failureForPrimary = (
|
||||
cause.reported_limits,
|
||||
{ cause, ...parserLimitRecovery(cause.reported_limits) },
|
||||
);
|
||||
if (cause instanceof PythonPycFormatFailure)
|
||||
return cause.kind === "unsupported"
|
||||
? new AnalysisUnsupportedTargetError(
|
||||
OPERATION,
|
||||
input.path,
|
||||
cause.message,
|
||||
{ cause },
|
||||
)
|
||||
: new AnalysisInputError(OPERATION, { cause }, [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_format",
|
||||
message: `Selected pyc ${input.path}: ${cause.message}`,
|
||||
},
|
||||
]);
|
||||
const formatFailure = parseFailureAnalysisError(OPERATION, input.path, cause);
|
||||
if (formatFailure !== undefined) return formatFailure;
|
||||
if (
|
||||
origin === "owned-or-classified" &&
|
||||
cause instanceof ArtifactReaderFailure
|
||||
|
||||
Reference in new issue
Block a user