Skip to main content
Version: v0.1.6

Warning and error codes

Every code @cosyte/astm returns or throws, by registry, with one line on what it means. Each code links to its entry in the API reference, which has the full rule. A code's name is part of the public contract: renaming or removing one is a breaking change.

Whether a vendor profile may tolerate a warning is decided by the library, and the answer can change between releases as codes are added, so ask isSafetyCriticalCode(code) rather than copying a list. Write a vendor profile explains the rule.

Record warnings: WARNING_CODES​

Returned on msg.warnings by parseAstmRecords, each with a record position and never a value.

CodeMeaning
ASTM_RECORD_UNKNOWN_TYPEA record's type letter is not a modeled type. The record is kept as an unsupported record; a header not recognized as one opens no new message, so two messages can merge.
ASTM_RECORD_FIELDS_UNSEPARATEDThe delimiters in force found no field separator in a record, so the whole line read as one field and none of its modeled fields survived.
ASTM_NONSTANDARD_DELIMITERSThe header declared a delimiter set other than the canonical H|\^&. The set is read and followed.
ASTM_RECORD_DELIMITER_ROLE_COLLISIONA header named one character in two of the repeat, component and escape roles, so the boundary between those two roles is not in the bytes.
ASTM_RECORD_DELIMITER_SWALLOWED_BY_ESCAPEAn escape sequence with an unrecognized body held a delimiter in force, so a boundary the bytes carried never became one.
ASTM_RECORD_AMBIGUOUS_ESCAPE_ALIGNMENTTwo alignments of the escape sequences disagree about one boundary, and the one taken split on a delimiter the other would have held.
ASTM_RECORD_ALIGNMENT_SHIFTED_FIELDSA contested boundary was a field boundary, so every later field, a result's units and status included, may sit in a different slot.
ASTM_RECORD_ALIGNMENT_TRUNCATED_FIELDA contested boundary was a repeat boundary, so a field may be read short: its value and components come from its first repeat alone.
ASTM_RECORD_ALIGNMENT_SHIFTED_COMPONENTSA contested boundary was a component boundary, so the components after it, such as a coding scheme or a given name, may sit in different slots.
ASTM_UNKNOWN_ESCAPE_SEQUENCEAn escape sequence's body was not F, S, R or E. It is kept as written.
ASTM_UNPAIRED_ESCAPE_CHARACTERAn escape character started no escape sequence. It is read as the literal character and kept.
ASTM_RECORD_AMBIGUOUS_VALUE_SPLITA result value held an unescaped component delimiter. The whole text and the split parts are both kept.
ASTM_RECORD_UNDEFINED_ABNORMAL_FLAGA result's abnormal flag is not a recognized letter. It reads undefined, never normal.
ASTM_RECORD_UNDEFINED_RESULT_STATUSA result's status is not a recognized letter. It reads undefined and is never active-final.
ASTM_RECORD_UNPARSEABLE_REFERENCE_RANGEA result's reference range is not low-high, <high or >low. It is kept as unparsed, with no bound invented.
ASTM_RECORD_UNITS_ABSENTA result had a numeric value and no units. The units stay empty; nothing is defaulted.
ASTM_RECORD_ORPHAN_COMMENTA comment record had no record before it to attach to. It is attached to the message itself and kept.
ASTM_RECORD_PARTIAL_TIMESTAMPA timestamp's digits stop halfway through a two-digit part. The value stops at the last whole part; nothing is filled with zeros.
ASTM_RECORD_UNINTERPRETED_QUERY_STATUSA query record carried a request-information status. It is kept as written and not interpreted.
ASTM_RECORD_AMBIGUOUS_MESSAGE_KINDThe stream carried both a query and a result. It is classified as a host query.
ASTM_RECORD_DELIMITERS_REDECLAREDA later header declared a different delimiter set, and the records after it are read with that set.
ASTM_RECORD_UNREADABLE_REDECLARATIONA later header could not declare a usable set, so the set already in force is kept.
PROFILE_QUIRK_APPLIEDA warning the active profile expects, re-badged. The original code is on toleratedCode.

Frame warnings: FRAME_WARNING_CODES​

Returned by decodeAstmFrames and on frameWarnings from parseFramedAstm, each with a frame number and byte offset. With { strict: true } they are thrown together as an AstmFrameStrictError.

CodeMeaning
ASTM_FRAME_BAD_CHECKSUMA frame's checksum did not match its bytes. The frame is kept untrusted and never merged into a record.
ASTM_FRAME_SEQUENCE_GAPA frame number was not the next one, so a frame may be missing. Records are not joined across the gap.
ASTM_FRAME_UNTERMINATEDA frame, or a record's run of frames, ended without its final terminator. No partial record is invented.
ASTM_FRAME_OVERSIZEA frame carried more than 240 bytes of text without a split. It is kept and flagged.

Transport warnings: LTP_WARNING_CODES​

Returned by detectFraming and ltpReduce.

CodeMeaning
ASTM_LTP_AMBIGUOUS_TRANSPORTThe leading byte did not say whether the stream is framed or raw, so framed was assumed.
ASTM_LTP_UNEXPECTED_EVENTA control event arrived in a state that did not expect it, such as an ACK at the receiver. It is never read as acceptance.
ASTM_LTP_FRAME_REJECTEDThe receiver answered a frame with NAK: bad checksum, unterminated, or out of sequence. Nothing from it is kept.

LOINC mapping warnings: LIVD_WARNING_CODES​

Returned by applyLivd, except the last, which is on the catalog's own warnings.

CodeMeaning
ASTM_LIVD_UNMAPPED_CODEThe catalog held no entry for a record's vendor code. No LOINC is guessed.
ASTM_LIVD_AMBIGUOUS_MAPPINGA vendor code matched several LOINCs that the units did not settle. All are listed and none is chosen.
ASTM_LIVD_CATALOG_NO_LOINC_VERSIONA catalog was defined without a LOINC version. Raised once, on catalog.warnings, and never a refusal.

Errors that always throw: FATAL_CODES​

Thrown by parseAstmRecords as an AstmParseError, in lenient mode too, when there is nothing to parse into a message.

CodeMeaning
EMPTY_INPUTThe input was empty or only whitespace.
ASTM_RECORD_NO_HEADERThe first record is not an H header.
ASTM_RECORD_UNDECLARED_DELIMITERSThe first header could not declare all four delimiters.

Errors from the flat accessors: AMBIGUOUS_CODES​

Thrown as an AstmAmbiguousStreamError by patient(), results(), orders(), comments() and query() on a stream they cannot answer for. Read a stream that carries several messages shows what to do instead.

CodeMeaning
ASTM_AMBIGUOUS_MULTI_MESSAGEA flat accessor was asked about a stream carrying more than one message.
ASTM_AMBIGUOUS_MULTI_PATIENTpatient() was asked about a message carrying more than one P record.

Errors from emit​

Thrown as an AstmSerializeError by the record serializer and builder (AstmSerializeErrorCode):

CodeMeaning
ASTM_EMIT_UNENCODABLE_VALUEA value holds CR or LF, which no escape sequence can carry.
ASTM_EMIT_INVALID_DELIMITERSThe delimiter set to write in is not one character each, holds CR or LF, or repeats a character.
ASTM_EMIT_TYPE_LETTER_COLLISIONA record's type letter would be escaped away under the set being written, so it would read back as another record.

Thrown as an AstmFrameEncodeError by composeAstmFrames and serializeFramedAstm (AstmFrameEncodeErrorCode):

CodeMeaning
ASTM_FRAME_EMPTY_RECORDAn empty record list, or a record with no bytes.
ASTM_FRAME_UNENCODABLE_CHARACTERA record given as a string holds a character above U+00FF.
ASTM_FRAME_RESERVED_BYTEA record holds STX, ETB or ETX, which only mark frame structure.
ASTM_FRAME_INVALID_START_FRAME_NUMBERstartFrameNumber is not a whole number from 0 to 7.

Write records and frames says what to do about each.

Errors from strict mode​

{ strict: true } turns warnings into thrown errors that carry them all: AstmStrictError from parseAstmRecords (record warnings) and AstmFrameStrictError from the frame decoder (frame warnings). AstmProfileDefinitionError is thrown by defineAstmProfile for a profile that breaks a rule, such as tolerating a code the safety gate refuses.