Skip to content

Commit 71259ec

Browse files
committed
Better error message for run_formatter
Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent c162b58 commit 71259ec

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/cfengine_cli/docs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import json
1313
import subprocess
14+
import textwrap
1415

1516
import markdown_it
1617
from cfbs.pretty import pretty_file
@@ -375,8 +376,11 @@ def _run_formatter(tool, args, cwd, install_hint):
375376
check=True,
376377
cwd=cwd,
377378
)
378-
except:
379-
raise UserError(f"Encountered an error running {tool}\nInstall: {install_hint}")
379+
except FileNotFoundError:
380+
raise UserError(f"'{tool}' not found. Install it with: {install_hint}")
381+
except subprocess.CalledProcessError as e:
382+
error_msg = textwrap.indent(str(e.stderr).strip(), "> ")
383+
raise UserError(f"Encountered an error running {tool}:\n{error_msg}")
380384
return result
381385

382386

0 commit comments

Comments
 (0)