diff --git a/Tools/BiblioTech/BaseGethCommand.cs b/Tools/BiblioTech/BaseGethCommand.cs index 49069953..104784cc 100644 --- a/Tools/BiblioTech/BaseGethCommand.cs +++ b/Tools/BiblioTech/BaseGethCommand.cs @@ -8,9 +8,13 @@ namespace BiblioTech { protected override async Task Invoke(CommandContext context) { - var gethConnector = GethConnector.GethConnector.Initialize(Program.Log); + var gethConnector = GetGeth(); + if (gethConnector == null) + { + await context.Followup("Blockchain operations are (temporarily) unavailable."); + return; + } - if (gethConnector == null) return; var gethNode = gethConnector.GethNode; var contracts = gethConnector.CodexContracts; @@ -23,6 +27,19 @@ namespace BiblioTech await Execute(context, gethNode, contracts); } + private GethConnector.GethConnector? GetGeth() + { + try + { + return GethConnector.GethConnector.Initialize(Program.Log); + } + catch (Exception ex) + { + Program.Log.Error("Failed to initialize geth connector: " + ex); + return null; + } + } + protected abstract Task Execute(CommandContext context, IGethNode gethNode, ICodexContracts contracts); } }