diff --git a/output.py b/output.py index 7d2f548..69b2369 100644 --- a/output.py +++ b/output.py @@ -38,6 +38,9 @@ def format_channel(channel, node1_alias, node2_alias, chanDisabled, show_fees): else: return text - +def format_channel_error(channelID, error): + text = f'{channelID:<18} ERROR: {error:<100}' + return chalk.bg_red(text) + def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear') diff --git a/status.py b/status.py index 1ade976..9d2a50d 100644 --- a/status.py +++ b/status.py @@ -1,7 +1,8 @@ import os +import grpc from time import sleep -from output import format_error, clear_screen, format_channel +from output import format_channel_error, format_error, clear_screen, format_channel LOOP_SLEEP_TIME = 10 @@ -41,12 +42,17 @@ class Status: if not channelID.isnumeric(): continue - response = self.lnd.get_edge(int(channelID)) - node1 = self.lnd.get_node(response.node1_pub) - node2 = self.lnd.get_node(response.node2_pub) - disabled = response.node1_policy.disabled or response.node2_policy.disabled - self.print_channel(response, node1.alias, node2.alias, disabled) - + try: + response = self.lnd.get_edge(int(channelID)) + node1 = self.lnd.get_node(response.node1_pub) + node2 = self.lnd.get_node(response.node2_pub) + disabled = response.node1_policy.disabled or response.node2_policy.disabled + self.print_channel(response, node1.alias, node2.alias, disabled) + except grpc.RpcError as e: + self.output.print_line(format_channel_error(channelID, e.details())) + except Exception as error: + self.output.print_line(format_channel_error(channelID, repr(error))) + def print_channel(self, channel, node1_alias, node2_alias, chan_disabled): self.output.print_line(format_channel(channel, node1_alias, node2_alias, chan_disabled, self.show_fees))