|
67 | 67 | ColumnDef, |
68 | 68 | ValidationError, |
69 | 69 | format_validation_error, |
| 70 | + ResultReporter, |
70 | 71 | ) |
71 | 72 |
|
72 | 73 |
|
@@ -141,7 +142,8 @@ def handle_mcp_discover_hosts(args: Namespace) -> int: |
141 | 142 | print(formatter.render()) |
142 | 143 | return EXIT_SUCCESS |
143 | 144 | except Exception as e: |
144 | | - print(f"Error discovering hosts: {e}") |
| 145 | + reporter = ResultReporter("hatch mcp discover hosts") |
| 146 | + reporter.report_error("Failed to discover hosts", details=[f"Reason: {str(e)}"]) |
145 | 147 | return EXIT_ERROR |
146 | 148 |
|
147 | 149 |
|
@@ -220,7 +222,8 @@ def handle_mcp_discover_servers(args: Namespace) -> int: |
220 | 222 |
|
221 | 223 | return EXIT_SUCCESS |
222 | 224 | except Exception as e: |
223 | | - print(f"Error discovering servers: {e}") |
| 225 | + reporter = ResultReporter("hatch mcp discover servers") |
| 226 | + reporter.report_error("Failed to discover servers", details=[f"Reason: {str(e)}"]) |
224 | 227 | return EXIT_ERROR |
225 | 228 |
|
226 | 229 |
|
@@ -360,7 +363,8 @@ def handle_mcp_list_hosts(args: Namespace) -> int: |
360 | 363 | print(formatter.render()) |
361 | 364 | return EXIT_SUCCESS |
362 | 365 | except Exception as e: |
363 | | - print(f"Error listing hosts: {e}") |
| 366 | + reporter = ResultReporter("hatch mcp list hosts") |
| 367 | + reporter.report_error("Failed to list hosts", details=[f"Reason: {str(e)}"]) |
364 | 368 | return EXIT_ERROR |
365 | 369 |
|
366 | 370 |
|
@@ -503,7 +507,8 @@ def handle_mcp_list_servers(args: Namespace) -> int: |
503 | 507 | print(formatter.render()) |
504 | 508 | return EXIT_SUCCESS |
505 | 509 | except Exception as e: |
506 | | - print(f"Error listing servers: {e}") |
| 510 | + reporter = ResultReporter("hatch mcp list servers") |
| 511 | + reporter.report_error("Failed to list servers", details=[f"Reason: {str(e)}"]) |
507 | 512 | return EXIT_ERROR |
508 | 513 |
|
509 | 514 |
|
@@ -722,7 +727,8 @@ def handle_mcp_show_hosts(args: Namespace) -> int: |
722 | 727 |
|
723 | 728 | return EXIT_SUCCESS |
724 | 729 | except Exception as e: |
725 | | - print(f"Error showing host configurations: {e}") |
| 730 | + reporter = ResultReporter("hatch mcp show hosts") |
| 731 | + reporter.report_error("Failed to show host configurations", details=[f"Reason: {str(e)}"]) |
726 | 732 | return EXIT_ERROR |
727 | 733 |
|
728 | 734 |
|
@@ -935,7 +941,8 @@ def handle_mcp_show_servers(args: Namespace) -> int: |
935 | 941 |
|
936 | 942 | return EXIT_SUCCESS |
937 | 943 | except Exception as e: |
938 | | - print(f"Error showing server configurations: {e}") |
| 944 | + reporter = ResultReporter("hatch mcp show servers") |
| 945 | + reporter.report_error("Failed to show server configurations", details=[f"Reason: {str(e)}"]) |
939 | 946 | return EXIT_ERROR |
940 | 947 |
|
941 | 948 |
|
@@ -1055,7 +1062,8 @@ def handle_mcp_backup_restore(args: Namespace) -> int: |
1055 | 1062 | return EXIT_ERROR |
1056 | 1063 |
|
1057 | 1064 | except Exception as e: |
1058 | | - print(f"Error restoring backup: {e}") |
| 1065 | + reporter = ResultReporter("hatch mcp backup restore") |
| 1066 | + reporter.report_error("Failed to restore backup", details=[f"Reason: {str(e)}"]) |
1059 | 1067 | return EXIT_ERROR |
1060 | 1068 |
|
1061 | 1069 |
|
@@ -1141,7 +1149,8 @@ def handle_mcp_backup_list(args: Namespace) -> int: |
1141 | 1149 |
|
1142 | 1150 | return EXIT_SUCCESS |
1143 | 1151 | except Exception as e: |
1144 | | - print(f"Error listing backups: {e}") |
| 1152 | + reporter = ResultReporter("hatch mcp backup list") |
| 1153 | + reporter.report_error("Failed to list backups", details=[f"Reason: {str(e)}"]) |
1145 | 1154 | return EXIT_ERROR |
1146 | 1155 |
|
1147 | 1156 |
|
@@ -1260,7 +1269,8 @@ def handle_mcp_backup_clean(args: Namespace) -> int: |
1260 | 1269 | return EXIT_SUCCESS |
1261 | 1270 |
|
1262 | 1271 | except Exception as e: |
1263 | | - print(f"Error cleaning backups: {e}") |
| 1272 | + reporter = ResultReporter("hatch mcp backup clean") |
| 1273 | + reporter.report_error("Failed to clean backups", details=[f"Reason: {str(e)}"]) |
1264 | 1274 | return EXIT_ERROR |
1265 | 1275 |
|
1266 | 1276 |
|
@@ -1527,7 +1537,8 @@ def handle_mcp_configure(args: Namespace) -> int: |
1527 | 1537 | return EXIT_ERROR |
1528 | 1538 |
|
1529 | 1539 | except Exception as e: |
1530 | | - print(f"Error configuring MCP server: {e}") |
| 1540 | + reporter = ResultReporter("hatch mcp configure") |
| 1541 | + reporter.report_error("Failed to configure MCP server", details=[f"Reason: {str(e)}"]) |
1531 | 1542 | return EXIT_ERROR |
1532 | 1543 |
|
1533 | 1544 |
|
@@ -1607,7 +1618,8 @@ def handle_mcp_remove(args: Namespace) -> int: |
1607 | 1618 | return EXIT_ERROR |
1608 | 1619 |
|
1609 | 1620 | except Exception as e: |
1610 | | - print(f"Error removing MCP server: {e}") |
| 1621 | + reporter = ResultReporter("hatch mcp remove") |
| 1622 | + reporter.report_error("Failed to remove MCP server", details=[f"Reason: {str(e)}"]) |
1611 | 1623 | return EXIT_ERROR |
1612 | 1624 |
|
1613 | 1625 |
|
@@ -1729,7 +1741,8 @@ def handle_mcp_remove_server(args: Namespace) -> int: |
1729 | 1741 | return EXIT_ERROR |
1730 | 1742 |
|
1731 | 1743 | except Exception as e: |
1732 | | - print(f"Error removing MCP server: {e}") |
| 1744 | + reporter = ResultReporter("hatch mcp remove-server") |
| 1745 | + reporter.report_error("Failed to remove MCP server", details=[f"Reason: {str(e)}"]) |
1733 | 1746 | return EXIT_ERROR |
1734 | 1747 |
|
1735 | 1748 |
|
@@ -1815,7 +1828,8 @@ def handle_mcp_remove_host(args: Namespace) -> int: |
1815 | 1828 | return EXIT_ERROR |
1816 | 1829 |
|
1817 | 1830 | except Exception as e: |
1818 | | - print(f"Error removing host configuration: {e}") |
| 1831 | + reporter = ResultReporter("hatch mcp remove-host") |
| 1832 | + reporter.report_error("Failed to remove host configuration", details=[f"Reason: {str(e)}"]) |
1819 | 1833 | return EXIT_ERROR |
1820 | 1834 |
|
1821 | 1835 |
|
@@ -1935,5 +1949,6 @@ def handle_mcp_sync(args: Namespace) -> int: |
1935 | 1949 | format_validation_error(ValidationError(str(e))) |
1936 | 1950 | return EXIT_ERROR |
1937 | 1951 | except Exception as e: |
1938 | | - print(f"Error during synchronization: {e}") |
| 1952 | + reporter = ResultReporter("hatch mcp sync") |
| 1953 | + reporter.report_error("Failed to synchronize", details=[f"Reason: {str(e)}"]) |
1939 | 1954 | return EXIT_ERROR |
0 commit comments