7.7 Reading errors, exit codes and hints
An nlmx failure contains several independent clues: elapsed time, severity, stage, primary message, exit code/class, recovery hint and whether a log file was attached. Read the complete block.
Stage and code
The stage says how far execution progressed. Both Chapter 7 negative tests failed during startup, before output-directory preparation. Therefore no run log was attached; the harness captured console output separately.
The wrong extension used exit code 2, labelled invalid CLI usage, because the requested output name for --print-config was invalid. The unknown key used exit code 4, labelled invalid configuration, because the supplied .power file could not be accepted. Scripts should test exit status, not search for one English phrase.
Location context
Parser failures can show line, column and a source excerpt. The caret marks where the parser identified the problem. For unknown fields, the expected-key list is especially useful for spelling and table-placement errors. If a familiar key is reported as unknown, verify that it appears under the correct [table].
Hints are actionable, not evidence of success
The extension hint suggests the corrected suffix and lists the registry. The unknown-key hint suggests generating an annotated reference. Follow the hint, but do not assume a renamed or edited file is scientifically correct; rerun validation.
Capturing early failures
Failures before output preparation cannot write into the requested output directory. A wrapper used for validation should capture stdout, stderr, exact arguments and exit code in an external log. pytools/ch07_examples.py demonstrates this pattern.
Common mistakes
- Reading only the first line and missing the hint or code.
- Expecting every startup failure to leave an output log.
- Treating exit code 2 and 4 as interchangeable.
Checklist
- Record the full console message and exit status.
- Use stage information to determine which artifacts can exist.
- Correct the cause, then rerun validation from the beginning.
Further reading
See extension enforcement, validation layers and Chapter 39's future troubleshooting reference.