Skip to content

Commit

Permalink
Merge pull request #777 from armintaenzertng/issue-773-catch-file-not…
Browse files Browse the repository at this point in the history
…-found

[issue-773] shorten output of FileNotFoundError when called via the CLI
  • Loading branch information
maxhbr authored Mar 22, 2024
2 parents 1e3031c + 119f187 commit e0c83cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/spdx_tools/spdx/clitools/pyspdxtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ def main(infile: str, outfile: str, version: str, novalidation: bool, graph: boo
logging.error(log_string)
sys.exit(1)

except FileNotFoundError as err:
logging.error(f"{err.strerror}: {err.filename}")
sys.exit(1)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions tests/spdx/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_cli_with_system_exit_code_0(options):
"data/invalid/spdx-trivy-vmware_log-intelligence-fluentd-sha256_086af034f561f343f633be9d9f9e95f65ae6c61b8ddb2c6755ef5bb25b40f53a.json", # noqa: E501
),
),
("-i", "non_existent_file.spdx"),
],
)
def test_cli_with_system_exit_code_1(options):
Expand Down

0 comments on commit e0c83cd

Please sign in to comment.