| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4c6025d commit 862fe72
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -267,6 +267,7 @@ def build_parser() -> argparse.ArgumentParser: | |||
| 267 | 267 | ||
| 268 | 268 | def main(argv: list[str] | None = None) -> int: | |
| 269 | 269 | """CLI entry point.""" | |
| 270 | + from inputlayer.exceptions import InputLayerError | ||
| 270 | 271 | from inputlayer.migrations.errors import MigrationError | |
| 271 | 272 | ||
| 272 | 273 | parser = build_parser() | |
@@ -278,7 +279,7 @@ def main(argv: list[str] | None = None) -> int: | |||
| 278 | 279 | ||
| 279 | 280 | try: | |
| 280 | 281 | return args.func(args) | |
| 281 | - except MigrationError as exc: | ||
| 282 | + except (MigrationError, InputLayerError) as exc: | ||
| 282 | 283 | print(f"error: {exc}") | |
| 283 | 284 | return 1 | |
| 284 | 285 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,21 @@ def test_build_parser(self): | |||
| 18 | 18 | def test_no_command_returns_1(self): | |
| 19 | 19 | assert main([]) == 1 | |
| 20 | 20 | ||
| 21 | + def test_connection_error_prints_cleanly(self, capsys, monkeypatch): | ||
| 22 | + # SDK errors (unreachable server, auth failure) must exit 1 with a | ||
| 23 | + # clean message, not a traceback. | ||
| 24 | + from inputlayer.exceptions import InputLayerConnectionError | ||
| 25 | + from inputlayer.migrations import cli | ||
| 26 | + | ||
| 27 | + def boom(args): | ||
| 28 | + raise InputLayerConnectionError("Failed to connect to ws://nope") | ||
| 29 | + | ||
| 30 | + monkeypatch.setattr(cli, "_cmd_showmigrations", boom) | ||
| 31 | + rc = main(["showmigrations", "--url", "ws://nope", "--kg", "k"]) | ||
| 32 | + assert rc == 1 | ||
| 33 | + out = capsys.readouterr().out | ||
| 34 | + assert "error: Failed to connect" in out | ||
| 35 | + | ||
| 21 | 36 | def test_makemigrations_requires_models(self): | |
| 22 | 37 | parser = build_parser() | |
| 23 | 38 | with pytest.raises(SystemExit): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments