mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
* 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
34 lines
1003 B
TypeScript
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");
|
|
};
|