Exit codes#
Every hmp verb maps its outcome to a typed exit code defined
in hydromodpy/cli/helpers.py. The same mapping powers
exit_code_for(exc), which routes Python exceptions to the matching
code. Scripts and CI gates can rely on the table below; new failure
categories reuse the 10..21 band before introducing new ranges.
Code |
Name |
Meaning |
|---|---|---|
0 |
|
Success. |
1 |
|
Generic failure with no specific mapping. |
2 |
|
Invalid CLI usage (argparse rejected the call). |
10 |
|
Missing file, workspace, simulation, or catalog row.
Raised for |
11 |
|
Catalog or lockfile schema does not match the running version. |
12 |
|
Concurrent writer detected on the catalog or workspace. |
13 |
|
Target opened read-only; the mutation was refused. |
14 |
|
Invalid or missing TOML / Pydantic configuration. |
15 |
|
Solver (MODFLOW 6, MODFLOW-NWT, Boussinesq, GR4J) failed. |
16 |
|
Data validation failed (units, ranges, schema constraints). |
17 |
|
Operation crossed project boundaries (forbidden). |
18 |
|
Required backup step failed during a destructive action. |
19 |
|
Workspace or catalog migration failed. |
20 |
|
A run reference matched several runs. Lengthen the id prefix or use the full name. |
21 |
|
Calibration loop failed: objective evaluation or optimizer backend raised an unrecoverable error. |
130 |
|
Interrupted by |
Exception mapping#
hydromodpy.cli.helpers.exit_code_for(exc) returns the typed code
for an exception instance. KeyboardInterrupt always maps to 130;
FileNotFoundError and an unresolved reference map to 10; an ambiguous
reference maps to 20. Domain exceptions defined in
hydromodpy.core.exceptions (SchemaVersionMismatchError,
WriteConflictError, ReadOnlyError, ConfigError,
ConfigMissingError, SolverError, DataError,
CrossProjectsError, BackupFailedError, MigrationFailedError)
map to codes 11..19 respectively. CalibrationError (and its
ObjectiveError / OptimizerError subclasses) maps to 21. Any other
exception falls back to EXIT_GENERIC (1).