fix(OSError): handle different OSErrors (#2398)

Co-authored-by: Sergio Garcia <sergargar1@gmail.com>
This commit is contained in:
kij
2023-05-23 17:16:17 +02:00
committed by GitHub
parent deb9847e2b
commit 71a789c0b4

View File

@@ -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:
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(