Documenting What Command Exit Codes Mean
An application can give meaning to success and failure statuses that callers use to control a workflow.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two non-success outcomes
A checking command may report that no records matched or that input could not be opened. Scripts should distinguish them if the command documents separate statuses. File errors explain an ordinary cause for the latter.
Verify output in each state
Test a valid empty result and a failed read under the declared convention. Do not infer result solely from a blank output stream. Exit status and output details those independent channels.[1]
Document which outcomes are completed queries
A search utility may reserve one status for a match, another for no matching item, and a distinct status for malformed input. A wrapper that treats every nonzero status as the same error can hide a valid empty result. Read the exact program contract. See decision and witness results.
Toy convention: 0=found, 1=missing, 2=invalid
Automation reads the status together with documented output
An absent result need not carry the same diagnostics as an invalid request
Assert statuses through the actual process interface
Different shells can represent signal-driven termination differently. Tests should include a bad argument, an ordinary absence and a successful invocation. Document whether a partial output accompanies any error outcome.