Class: Hl7ParseError
Thrown by parseHL7 when the input violates one of the 4 unrecoverable
Tier-3 structural rules (missing MSH, truncated MSH, invalid encoding
characters, or empty input). Carries positional context plus a short
snippet of the offending input so consumers can log actionable errors.
Remarks
Snippets may contain PHI when parsing real clinical messages: redact at the call site if required by your compliance posture. The library does not redact snippets itself.
Example
import { parseHL7, Hl7ParseError } from "@cosyte/hl7";
try {
parseHL7("");
} catch (err) {
if (err instanceof Hl7ParseError && err.code === "EMPTY_INPUT") {
// handle empty input: err.position, err.snippet available
}
}
Extends
Error
Constructors
Constructor
new Hl7ParseError(
code,message,position,snippet):Hl7ParseError
Internal
Construct a new Hl7ParseError. All four fields are required so every
thrower populates full positional context per the TOL-02 requirement.
Parameters
code
message
string
position
snippet
string
Returns
Hl7ParseError
Overrides
Error.constructor
Properties
code
readonlycode:FatalCode
position
readonlyposition:Hl7Position
snippet
readonlysnippet:string