⚠️ This is pre-release documentation for v3. For stable docs, visit v2.
Skip to content

Diagnostic codes ​

Every error thrown by, and every diagnostic returned by, @tmlmt/cooklang-parser has a stable code of the form COOKLANG_<L><T><D><NN>:

  • L is the letter: E for an error, W for a warning, or I for an internal/library bug.
  • T is a tier digit used only for E codes: 0 for recoverable errors, which are collected while parsing continues and do not make the call throw, so the partial result stays available. 9 for fatal errors, where it is not safe to continue and the call throws. It is always 0 for W and I codes.
  • D is the domain: 0 generic/internal, 1 recipe syntax, 2 references, 3 metadata, 4 quantities and units, 5 shopping list, 6 shopping cart and product catalog, or 7 pantry and category configuration.
  • NN is a two-digit sequence number.

Warnings never make a call fail. Internal errors indicate a library bug and behave like fatal errors. Fatal errors stop the affected work when detected and make the call throw a DiagnosticError, which carries the diagnostics collected up to that point.

See the parse diagnostics guide to learn how to consume them.

CodeLevelTitle
COOKLANG_E0101errorInvalid quantity
COOKLANG_E0102errorTimer missing unit
COOKLANG_E0201errorReferenced ingredient not found
COOKLANG_E0202errorReferenced cookware not found
COOKLANG_E0203errorReferenced cookware flags do not match
COOKLANG_E0204errorReferenced ingredient properties do not match
COOKLANG_E0301errorTab used for indentation
COOKLANG_E0302errorInconsistent indentation
COOKLANG_E0701errorInvalid date
COOKLANG_E0702errorDuplicate category
COOKLANG_E9401error(fatal)Ratio cannot be computed
COOKLANG_E9402error(fatal)Division by zero
COOKLANG_E9501error(fatal)Unresolved alternatives
COOKLANG_E9502error(fatal)Index out of bounds
COOKLANG_E9503error(fatal)Unknown recipe path
COOKLANG_E9504error(fatal)Invalid pantry
COOKLANG_E9505error(fatal)Invalid category configuration
COOKLANG_E9601error(fatal)Invalid product catalog TOML
COOKLANG_E9602error(fatal)Invalid product catalog format
COOKLANG_E9603error(fatal)No product catalog for cart
COOKLANG_E9604error(fatal)No shopping list for cart
COOKLANG_E9701error(fatal)Invalid pantry TOML
COOKLANG_I0401error(internal)Incompatible units
COOKLANG_W0101warningUnterminated block comment
COOKLANG_W0201warningDuplicate ingredient without reference
COOKLANG_W0202warningDuplicate cookware without reference
COOKLANG_W0301warningServings is not a number
COOKLANG_W0401warningText quantities kept separate
COOKLANG_W0601warningNo product match
COOKLANG_W0701warningIngredient without category
COOKLANG_W0702warningDuplicate ingredient or alias