Skip to main content
Version: v0.0.3

Type Alias: FatalCode

FatalCode = typeof FATAL_CODES[keyof typeof FATAL_CODES]

Discriminant type for Hl7ParseError.code. Narrowing a caught error by this code lets consumers write exhaustive switch blocks (enabled by the switch-exhaustiveness-check lint rule) and guarantees a typo-free comparison against the FATAL_CODES registry.

Example

import type { FatalCode } from "@cosyte/hl7";
function describe(code: FatalCode): string {
switch (code) {
case "EMPTY_INPUT":
return "input was empty";
case "NO_MSH_SEGMENT":
return "missing MSH";
case "MSH_TOO_SHORT":
return "MSH truncated";
case "INVALID_ENCODING_CHARACTERS":
return "bad MSH-1/MSH-2";
}
}