This PR swaps the exit codes for business logic errors (APP_ERROR, previously 2) and malformed CLIs (USAGE_ERROR, previously 3). That's because a large range of usage errors are not caught by our own code but by argparse's internal logic and argparse exits with a hard-coded code of 2. In the interest of unifying the exit code for any type of usage error, we must also exit with 2 in our own logic.
Additionally, some refactoring of exit codes and usage error output has been done.
The private module-level constants (which have been imported elsewhere even though being meant to be private) have been replaced with an enumeration.
Console output from our usage_error() function now more closely resembles what argparse prints for the errors it catches internally.
This PR swaps the exit codes for business logic errors (APP_ERROR, previously 2) and malformed CLIs (USAGE_ERROR, previously 3). That's because a large range of usage errors are not caught by our own code but by argparse's internal logic and argparse exits with a hard-coded code of 2. In the interest of unifying the exit code for any type of usage error, we must also exit with 2 in our own logic.
Additionally, some refactoring of exit codes and usage error output has been done. The private module-level constants (which have been imported elsewhere even though being meant to be private) have been replaced with an enumeration. Console output from our
usage_error()
function now more closely resembles what argparse prints for the errors it catches internally.