mirror of
https://github.com/StijnBTC/Ringtools.git
synced 2025-02-28 07:54:09 +01:00
RPC error handling (eg edge not found)
This commit is contained in:
parent
4c1a0822f0
commit
8d65bc7677
2 changed files with 17 additions and 8 deletions
|
@ -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')
|
||||
|
|
20
status.py
20
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))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue