Skip to content

Error Scenarios

The demo CLI ships with five built-in error scenarios. Each one emits both a human-readable message and a cli.error.v0.1 JSON payload.

CommandError IDCodeDescription
demo-cli network-timeoutDEMO.NETWORK.TIMEOUTDEM001HTTP request timed out
demo-cli config-missingDEMO.CONFIG.MISSINGDEM002Missing configuration file
demo-cli auth-failedDEMO.AUTH.INVALID_TOKENDEM003Authentication failure
demo-cli permission-deniedDEMO.FS.PERMISSION_DENIEDDEM004File permission error
demo-cli validation-errorDEMO.VALIDATION.SCHEMADEM005Schema validation failure

Every command accepts --json-out <path> to write the JSON payload to a file.

The human-readable format prints to stdout in a predictable structure that a11y-lint scores highly:

[ERROR] Request timed out (ID: DEMO.NETWORK.TIMEOUT)
What:
The HTTP request did not complete within 30 seconds.
Why:
The server did not respond before the timeout limit.
This may indicate network congestion or server overload.
Fix:
Check your network connection.
Verify the server is reachable: ping api.example.com
Re-run with increased timeout: demo-cli network-timeout --timeout 60 --dry-run

The pattern is always: [LEVEL] Title (ID: <dot-namespaced-id>) followed by What, Why, and Fix sections. Each section contains one or more indented lines.

The same error emits cli.error.v0.1 JSON to stderr (and optionally to a file via --json-out):

{
"level": "ERROR",
"code": "DEM001",
"id": "DEMO.NETWORK.TIMEOUT",
"title": "Request timed out",
"what": ["The HTTP request did not complete within 30 seconds."],
"why": [
"The server did not respond before the timeout limit.",
"This may indicate network congestion or server overload."
],
"fix": [
"Check your network connection.",
"Verify the server is reachable: ping api.example.com",
"Re-run with increased timeout: demo-cli network-timeout --timeout 60 --dry-run"
]
}

This JSON is the ground truth that a11y-assist reads and transforms for each accessibility profile.

Terminal window
for cmd in network-timeout config-missing auth-failed permission-denied validation-error; do
echo "=== $cmd ==="
demo-cli "$cmd" --json-out "/tmp/${cmd}.json"
echo ""
done

After capturing JSON output, validate that it conforms to the contract:

Terminal window
a11y-lint validate /tmp/network-timeout.json