Do not spam logs if we can't connect to lightning because lightning is not started

This commit is contained in:
nicolas.dorier 2019-03-20 14:35:33 +09:00
parent be90172840
commit 2a302ea346

View File

@ -100,13 +100,25 @@ namespace BTCPayServer.Payments.Lightning
{
var charge = lightningSupportedMethod.CreateClient(network);
LightningInvoice chargeInvoice = null;
string errorMessage = $"{lightningSupportedMethod.CryptoCode} (Lightning): Can't connect to the lightning server";
try
{
chargeInvoice = await charge.GetInvoice(lightningMethod.InvoiceId);
}
catch (System.Net.Sockets.SocketException socketEx) when (socketEx.SocketErrorCode == System.Net.Sockets.SocketError.ConnectionRefused)
{
Logs.PayServer.LogError(errorMessage);
continue;
}
catch (Exception ex) when (ex.InnerException is System.Net.Sockets.SocketException socketEx
&& socketEx.SocketErrorCode == System.Net.Sockets.SocketError.ConnectionRefused)
{
Logs.PayServer.LogError(errorMessage);
continue;
}
catch (Exception ex)
{
Logs.PayServer.LogError(ex, $"{lightningSupportedMethod.CryptoCode} (Lightning): Can't connect to the lightning server");
Logs.PayServer.LogError(ex, errorMessage);
continue;
}
if (chargeInvoice == null)