diff --git a/prowler/lib/utils/utils.py b/prowler/lib/utils/utils.py index 8a1f5484..83da5f04 100644 --- a/prowler/lib/utils/utils.py +++ b/prowler/lib/utils/utils.py @@ -16,10 +16,13 @@ from prowler.lib.logger import logger def open_file(input_file: str, mode: str = "r") -> TextIOWrapper: try: f = open(input_file, mode) - except OSError: - logger.critical( - "Ooops! You reached your user session maximum open files. To solve this issue, increase the shell session limit by running this command `ulimit -n 4096`. For more info visit https://docs.prowler.cloud/en/latest/troubleshooting/" - ) + except OSError as ose: + if ose.strerror == "Too many open files": + logger.critical( + "Ooops! You reached your user session maximum open files. To solve this issue, increase the shell session limit by running this command `ulimit -n 4096`. For more info visit https://docs.prowler.cloud/en/latest/troubleshooting/" + ) + else: + logger.critical(f"{input_file}: OSError[{ose.errno}] {ose.strerror}") sys.exit(1) except Exception as e: logger.critical(