Skip to content

Commit bc31a61

Browse files
committed
handle more exceptions
1 parent 7f01823 commit bc31a61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ def check_formatter_installed(formatter_cmds: list[str]) -> bool:
2323
for command in set(formatter_cmds):
2424
formatter_cmd_list = shlex.split(command, posix=os.name != "nt")
2525
formatter_cmd_list = [tmp_file.as_posix() if chunk == file_token else chunk for chunk in formatter_cmd_list]
26-
result = subprocess.run(formatter_cmd_list, capture_output=True, check=False)
26+
try:
27+
result = subprocess.run(formatter_cmd_list, capture_output=True, check=False)
28+
except (FileNotFoundError, NotADirectoryError):
29+
return_code = False
30+
break
2731
if result.returncode:
2832
return_code = False
2933
break
3034
tmp_file.unlink(missing_ok=True)
3135
if not return_code:
32-
raise logger.error(f"Error running formatter command: {command}")
36+
msg = f"Error running formatter command: {command}"
37+
raise logger.error(msg) # type: ignore
3338
return return_code
3439

3540

0 commit comments

Comments
 (0)