mirror of
https://github.com/StijnBTC/Ringtools.git
synced 2025-02-28 15:55:27 +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:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
def format_channel_error(channelID, error):
|
||||||
|
text = f'{channelID:<18} ERROR: {error:<100}'
|
||||||
|
return chalk.bg_red(text)
|
||||||
|
|
||||||
def clear_screen():
|
def clear_screen():
|
||||||
os.system('cls' if os.name == 'nt' else 'clear')
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import os
|
import os
|
||||||
|
import grpc
|
||||||
from time import sleep
|
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
|
LOOP_SLEEP_TIME = 10
|
||||||
|
|
||||||
|
@ -41,11 +42,16 @@ class Status:
|
||||||
if not channelID.isnumeric():
|
if not channelID.isnumeric():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
response = self.lnd.get_edge(int(channelID))
|
response = self.lnd.get_edge(int(channelID))
|
||||||
node1 = self.lnd.get_node(response.node1_pub)
|
node1 = self.lnd.get_node(response.node1_pub)
|
||||||
node2 = self.lnd.get_node(response.node2_pub)
|
node2 = self.lnd.get_node(response.node2_pub)
|
||||||
disabled = response.node1_policy.disabled or response.node2_policy.disabled
|
disabled = response.node1_policy.disabled or response.node2_policy.disabled
|
||||||
self.print_channel(response, node1.alias, node2.alias, 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):
|
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))
|
self.output.print_line(format_channel(channel, node1_alias, node2_alias, chan_disabled, self.show_fees))
|
||||||
|
|
Loading…
Add table
Reference in a new issue