Skip to main content
Version: v0.0.7

Class: X12ParseError

Thrown by parseX12 when the input violates one of the 4 unrecoverable Tier-3 structural rules (missing ISA, truncated ISA, invalid ISA delimiters, or empty input). Carries positional context plus a short snippet of the offending input so consumers can log actionable errors.

Remarks

snippet is the library's ONE deliberate PHI exception, and it exists for the four Tier-3 structural fatals only. Those are raised before the envelope is readable and are undebuggable without a few bytes of context. It may contain PHI/PII when parsing real interchanges (member IDs appear in ISA-06/08 only as trading-partner IDs, not patient identity, but a real claim / eligibility body elsewhere in the input can carry PHI). Redact at the call site if required by your compliance posture; the library does not redact snippets itself.

A strict-mode escalation of a Tier-2 warning carries snippet: "". That error's message is the same frozen-registry entry the warning carried and position locates it, so there is nothing to attach and nothing to redact.

Example

import { parseX12, X12ParseError } from "@cosyte/x12";
try {
parseX12("");
} catch (err) {
if (err instanceof X12ParseError && err.code === "X12_EMPTY_INPUT") {
// handle empty input - err.position, err.snippet available
}
}

Extends

  • Error

Constructors

Constructor

new X12ParseError(code, message, position, snippetText): X12ParseError

Internal

Construct a new X12ParseError. All four fields are required so every thrower populates full positional context.

Parameters

code

X12FatalCode

message

string

position

X12Position

snippetText

string

Returns

X12ParseError

Overrides

Error.constructor

Properties

code

readonly code: X12FatalCode


position

readonly position: X12Position


snippet

readonly snippet: string