Files
reverse-engineering-anything/src/artifacts/AndroidParserFailure.ts
T
Vincent Koc 6625dc153b refactor(artifacts): share Android parser limit projection (#15469)
* refactor(artifacts): share Android parser limit projection

* fix(artifacts): accept specialized parser failure facts

* fix(artifacts): use the resources entry point

* fix(verify): register the shared Android ceiling forwarder
2026-12-01 12:54:30 +00:00

34 lines
1003 B
TypeScript

import type { ParseFailureError } from "../domain/parseFailure.js";
import {
artifactFixedLimitFailure,
artifactParseFailure,
} from "../resources/index.js";
/** Project fixed parser limits without replacing the parser's reported maximum or cause. */
export const androidParserFailure =
(
limits: ReadonlyMap<
string,
{ readonly name: string; readonly unit: string }
>,
) =>
(failure: Pick<ParseFailureError, "failure" | "message">): unknown => {
const facts = failure.failure;
if (facts.kind === "limit") {
const ceiling = limits.get(facts.limit.name);
if (ceiling !== undefined)
return artifactFixedLimitFailure(
{
name: ceiling.name,
kind: "parser",
limit: facts.limit.maximum,
unit: ceiling.unit,
},
failure.message,
"capacity",
{ cause: failure },
);
}
return artifactParseFailure(failure, undefined, () => "capacity");
};