From 71259ec418f4c5494921d4e92c3548539f7dcbda Mon Sep 17 00:00:00 2001 From: Victor Moene Date: Fri, 10 Jul 2026 11:49:28 +0200 Subject: [PATCH] Better error message for run_formatter Signed-off-by: Victor Moene --- src/cfengine_cli/docs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cfengine_cli/docs.py b/src/cfengine_cli/docs.py index 83ebbcf..6821182 100644 --- a/src/cfengine_cli/docs.py +++ b/src/cfengine_cli/docs.py @@ -11,6 +11,7 @@ import os import json import subprocess +import textwrap import markdown_it from cfbs.pretty import pretty_file @@ -375,8 +376,11 @@ def _run_formatter(tool, args, cwd, install_hint): check=True, cwd=cwd, ) - except: - raise UserError(f"Encountered an error running {tool}\nInstall: {install_hint}") + except FileNotFoundError: + raise UserError(f"'{tool}' not found. Install it with: {install_hint}") + except subprocess.CalledProcessError as e: + error_msg = textwrap.indent(str(e.stderr).strip(), "> ") + raise UserError(f"Encountered an error running {tool}:\n{error_msg}") return result