BLE001: don't catch blind errors

This commit is contained in:
Jörg Thalheim
2025-08-20 15:59:24 +02:00
parent dc5485d9f1
commit d1cf87d2ce
2 changed files with 3 additions and 3 deletions

View File

@@ -179,7 +179,7 @@ def run_git_command(command: list) -> tuple[int, str, str]:
try: try:
result = subprocess.run(command, capture_output=True, text=True, check=False) result = subprocess.run(command, capture_output=True, text=True, check=False)
return result.returncode, result.stdout.strip(), result.stderr.strip() return result.returncode, result.stdout.strip(), result.stderr.strip()
except Exception as e: except (OSError, subprocess.SubprocessError) as e:
return 1, "", str(e) return 1, "", str(e)

View File

@@ -16,7 +16,7 @@ def _get_filepath(record: logging.LogRecord) -> Path:
try: try:
filepath = Path(record.pathname).resolve() filepath = Path(record.pathname).resolve()
filepath = Path("~", filepath.relative_to(Path.home())) filepath = Path("~", filepath.relative_to(Path.home()))
except Exception: except ValueError:
filepath = Path(record.pathname) filepath = Path(record.pathname)
return filepath return filepath
@@ -117,7 +117,7 @@ def get_callers(start: int = 2, end: int = 2) -> list[str]:
try: try:
filepath = Path(frame_info.filename).resolve() filepath = Path(frame_info.filename).resolve()
filepath = Path("~", filepath.relative_to(Path.home())) filepath = Path("~", filepath.relative_to(Path.home()))
except Exception: except ValueError:
filepath = Path(frame_info.filename) filepath = Path(frame_info.filename)
ret = f"{filepath}:{frame_info.lineno}::{frame_info.function}" ret = f"{filepath}:{frame_info.lineno}::{frame_info.function}"