diff --git a/cve_bin_tool/cli.py b/cve_bin_tool/cli.py index 91578d6bf0..84753d8db4 100644 --- a/cve_bin_tool/cli.py +++ b/cve_bin_tool/cli.py @@ -63,6 +63,7 @@ InsufficientArgs, InvalidExtensionError, MirrorError, + PDFOutputUnavailable, excepthook, ) from cve_bin_tool.input_engine import InputEngine, TriageData @@ -893,11 +894,14 @@ def main(argv=None): # Check for PDF support if "pdf" in output_formats and importlib.util.find_spec("reportlab") is None: - LOGGER.info("PDF output not available.") - LOGGER.info( + LOGGER.error("PDF output not available.") + LOGGER.error( "If you want to produce PDF output, please install reportlab using pip install reportlab" ) output_formats.remove("pdf") + if len(output_formats) < 1: + # If there's no other formats selected, exit so people actually see the error + return ERROR_CODES[PDFOutputUnavailable] merged_reports = None if args["merge"]: diff --git a/cve_bin_tool/error_handler.py b/cve_bin_tool/error_handler.py index 904785d1d1..51727d0d90 100644 --- a/cve_bin_tool/error_handler.py +++ b/cve_bin_tool/error_handler.py @@ -145,6 +145,10 @@ class NetworkConnectionError(Exception): """Raised when issue occurred with internet connection""" +class PDFOutputUnavailable(Exception): + """Raised when reportlab is not installed and PDF output is unavailable""" + + class ErrorMode(Enum): Ignore = 0 NoTrace = 1 @@ -246,4 +250,5 @@ def __exit__(self, exc_type, exc_val, exc_tb): InvalidExtensionError: 42, SigningError: 43, NetworkConnectionError: 44, + PDFOutputUnavailable: 45, } diff --git a/test/test_cli.py b/test/test_cli.py index b6d420a35d..a2ae5a67e6 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -706,7 +706,7 @@ def test_console_output_depending_reportlab_existence(self, caplog): assert ( "cve_bin_tool", - logging.INFO, + logging.ERROR, not_installed_msg, ) in caplog.record_tuples