Skip to main content
Version: v0.0.2

Function: parseFailureResult()

parseFailureResult(format, bytes, posture, e): RunResult

Build the value-free RunResult for a wrapped-parser rejection: a CLI_PARSE_FAILED data error (exit 65). The stderr line names the format and, when the thrown value carried one, a stable code token in parentheses; it never echoes the parser's message or the input bytes. Under --unsafe-show-values (and only then) a bounded excerpt of the offending input is appended via the single unsafeInputSuffix chokepoint.

Parameters

format

CosyteFormat

The format whose parser rejected the input.

bytes

Uint8Array

The offending input (only consulted for the opt-in unsafe excerpt).

posture

PhiPosture

The resolved PhiPosture; the excerpt is appended only when it opts in.

e

unknown

The caught exception (its code, if a stable token, is surfaced: nothing else).

Returns

RunResult

A value-free CLI_PARSE_FAILED / exit-65 RunResult.

Example

import { parseFailureResult, VALUE_FREE } from "@cosyte/cli";

const bytes = new TextEncoder().encode("not hl7");
parseFailureResult("hl7", bytes, VALUE_FREE, { code: "MISSING_MSH" }).exit; // => 65