Skip to content

Commit

Permalink
Improve exception reporting for chia farm summary
Browse files Browse the repository at this point in the history
With this change, only the exceptions when failing to connect to a local
full node and/or wallet are suppressed, as these cases are already
properly handled by adjusted command output. Any other exception is
printed to stderr.
  • Loading branch information
xearl4 committed Sep 22, 2023
1 parent a93ff99 commit 697b89c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions chia/cmds/farm_funcs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import sys
import traceback

from pathlib import Path
from typing import Any, Dict, List, Optional

Expand All @@ -10,6 +13,7 @@
from chia.rpc.full_node_rpc_client import FullNodeRpcClient
from chia.rpc.wallet_rpc_client import WalletRpcClient
from chia.util.default_root import DEFAULT_ROOT_PATH
from chia.util.errors import CliRpcConnectionError
from chia.util.misc import format_bytes, format_minutes
from chia.util.network import is_localhost

Expand Down Expand Up @@ -89,18 +93,26 @@ async def summary(
root_path: Path = DEFAULT_ROOT_PATH,
) -> None:
harvesters_summary = await get_harvesters_summary(farmer_rpc_port, root_path)
blockchain_state = None
try:
blockchain_state = await get_blockchain_state(rpc_port, root_path)
except CliRpcConnectionError:
pass
except Exception:
blockchain_state = None
print("Error while trying to get blockchain state!", file=sys.stderr)
traceback.print_exc(file=sys.stderr)

farmer_running = False if harvesters_summary is None else True # harvesters uses farmer rpc too

wallet_not_ready: bool = False
amounts = None
try:
amounts = await get_wallets_stats(wallet_rpc_port, root_path)
except Exception:
except CliRpcConnectionError:
wallet_not_ready = True
except Exception:
print("Error while trying to get wallet stats!", file=sys.stderr)
traceback.print_exc(file=sys.stderr)
wallet_not_running: bool = True if amounts is None else False

print("Farming status: ", end="")
Expand Down

0 comments on commit 697b89c

Please sign in to comment.