Skip to content

Commit 44c4091

Browse files
committed
add error handling around get_example_activity
1 parent bdbcdc4 commit 44c4091

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

resources/plugins/simln/simln.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
lightning_selector = "mission=lightning"
2222

2323

24+
class SimLNError(Exception):
25+
pass
26+
27+
2428
def run_simln():
2529
"""Run a SimLN Plugin demo"""
2630
init_network()
@@ -48,8 +52,13 @@ def _prepare_and_launch_activity() -> str:
4852
def get_example_activity() -> list[dict]:
4953
"""Get an activity representing node 2 sending msat to node 3"""
5054
pods = get_pods_with_label(lightning_selector)
51-
pod_a = pods[1].metadata.name
52-
pod_b = pods[2].metadata.name
55+
try:
56+
pod_a = pods[1].metadata.name
57+
pod_b = pods[2].metadata.name
58+
except Exception as err:
59+
raise SimLNError(
60+
"Could not access the lightning nodes needed for the example.\n Try deploying some."
61+
) from err
5362
return [{"source": pod_a, "destination": pod_b, "interval_secs": 1, "amount_msat": 2000}]
5463

5564

0 commit comments

Comments
 (0)