File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ public abstract class BaseGethCommand : BaseCommand
8
8
{
9
9
protected override async Task Invoke ( CommandContext context )
10
10
{
11
- var gethConnector = GethConnector . GethConnector . Initialize ( Program . Log ) ;
11
+ var gethConnector = GetGeth ( ) ;
12
+ if ( gethConnector == null )
13
+ {
14
+ await context . Followup ( "Blockchain operations are (temporarily) unavailable." ) ;
15
+ return ;
16
+ }
12
17
13
- if ( gethConnector == null ) return ;
14
18
var gethNode = gethConnector . GethNode ;
15
19
var contracts = gethConnector . CodexContracts ;
16
20
@@ -23,6 +27,19 @@ protected override async Task Invoke(CommandContext context)
23
27
await Execute ( context , gethNode , contracts ) ;
24
28
}
25
29
30
+ private GethConnector . GethConnector ? GetGeth ( )
31
+ {
32
+ try
33
+ {
34
+ return GethConnector . GethConnector . Initialize ( Program . Log ) ;
35
+ }
36
+ catch ( Exception ex )
37
+ {
38
+ Program . Log . Error ( "Failed to initialize geth connector: " + ex ) ;
39
+ return null ;
40
+ }
41
+ }
42
+
26
43
protected abstract Task Execute ( CommandContext context , IGethNode gethNode , ICodexContracts contracts ) ;
27
44
}
28
45
}
You can’t perform that action at this time.
0 commit comments