Festo-se / cyclonedx-editor-validator

Tool for creating, modifying and validating CycloneDX SBOMs.
https://festo-se.github.io/cyclonedx-editor-validator/
GNU General Public License v3.0
16 stars 4 forks source link

fix: Unify exit code for usage errors #187

Closed mmarseu closed 1 month ago

mmarseu commented 2 months ago

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.

github-actions[bot] commented 2 months ago

Coverage

Coverage Report •
FileStmtsMissCoverMissing
__main__.py3151595%215–216, 233, 640–641, 645–650, 652, 655, 667–668
TOTAL16016695% 

Tests Skipped Failures Errors Time
285 2 :zzz: 0 :x: 0 :fire: 4.759s :stopwatch: