MCPcopy Create free account
hub / github.com/InsForge/InsForge / wrapper

Function wrapper

examples/python-ml-experiment-tracker/tracker/cli.py:49–70  ·  view source on GitHub ↗

Invoke the wrapped command, translating known exceptions to user-facing output.

(*args, **kwargs)

Source from the content-addressed store, hash-verified

47 """Decorator that converts tracker exceptions into stderr messages and SystemExit(1)."""
48 @functools.wraps(fn)
49 def wrapper(*args, **kwargs):
50 """Invoke the wrapped command, translating known exceptions to user-facing output."""
51 try:
52 return fn(*args, **kwargs)
53 except AuthError as e:
54 err_console.print(f"[bold red]Auth error:[/] {e}")
55 raise SystemExit(1)
56 except APIError as e:
57 err_console.print(f"[bold red]API error {e.status_code}:[/] {e.message}")
58 raise SystemExit(1)
59 except httpx.ConnectError:
60 cfg = load_config()
61 err_console.print(
62 f"[bold red]Connection refused.[/] Is InsForge running at {cfg.server_url}?"
63 )
64 raise SystemExit(1)
65 except httpx.TimeoutException:
66 err_console.print("[bold red]Request timed out.[/]")
67 raise SystemExit(1)
68 except httpx.RequestError as e:
69 err_console.print(f"[bold red]Network error:[/] {e}")
70 raise SystemExit(1)
71 return wrapper
72
73

Callers 1

handleMessageFunction · 0.85

Calls 1

load_configFunction · 0.90

Tested by

no test coverage detected