Choose a stable error vocabulary for a local CLI
Give missing input a stable category
Path.exists observes the synthetic candidate before processing. The false result becomes the fixed token missing-input, so an automation client can react to a documented category rather than parsing a platform exception message. The assertion covers the absent-path branch.
Existence is not a reservation: the path can disappear after the check, and a later read can fail for another reason. Handle that actual read separately; this vocabulary only classifies the preflight absence.
Example
from pathlib import Path
from tempfile import TemporaryDirectory
with TemporaryDirectory() as d:
p = Path(d) / 'absent'
result = 'missing-input' if not p.exists() else 'ok'
assert result == 'missing-input'
result = 'kind=' + result
print(result)
Expected stdout:
kind=missing-input
Sources
Prepared with AI assistance. The example uses synthetic data; its stated limits apply.
Comments
Post a Comment