Skip to main content
Version: v0.0.3

Type Alias: FatalCode

FatalCode = typeof FATAL_CODES[keyof typeof FATAL_CODES]

Discriminant type for CcdaParseError.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/ccda";
function describe(code: FatalCode): string {
switch (code) {
case "XXE_OR_DTD_PRESENT":
return "document declared a DTD or external entity";
case "ENTITY_EXPANSION_LIMIT":
return "too many entity expansions";
case "INPUT_SIZE_LIMIT_EXCEEDED":
return "input too large";
case "ELEMENT_DEPTH_LIMIT_EXCEEDED":
return "nesting too deep";
case "NODE_COUNT_LIMIT_EXCEEDED":
return "too many elements";
case "NOT_WELL_FORMED_XML":
return "XML did not parse";
case "NOT_A_CLINICAL_DOCUMENT":
return "root element is not ClinicalDocument";
}
}