Merge pull request 'Report Lndhub API errors to Sentry' (#133) from refactor/lndhub_integration into master
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #133
This commit was merged in pull request #133.
This commit is contained in:
2023-06-06 15:44:36 +00:00
4 changed files with 21 additions and 72 deletions

View File

@@ -37,8 +37,8 @@ class Services::LightningController < ApplicationController
session[:ln_auth_token] = auth_token
@ln_auth_token = auth_token
end
rescue
# TODO add exception tracking
rescue => e
Sentry.capture_exception(e) if Setting.sentry_enabled?
end
def set_current_section
@@ -49,9 +49,9 @@ class Services::LightningController < ApplicationController
lndhub = Lndhub.new
data = lndhub.balance @ln_auth_token
@balance = data["BTC"]["AvailableBalance"] rescue nil
rescue
rescue AuthError
authenticate_with_lndhub(force_reauth: true)
return nil if @fetch_balance_retried
raise if @fetch_balance_retried
@fetch_balance_retried = true
fetch_balance
end
@@ -61,9 +61,9 @@ class Services::LightningController < ApplicationController
txs = lndhub.gettxs @ln_auth_token
invoices = lndhub.getuserinvoices(@ln_auth_token).select{|i| i["ispaid"]}
process_transactions(txs + invoices)
rescue
rescue AuthError
authenticate_with_lndhub(force_reauth: true)
return [] if @fetch_transactions_retried
raise if @fetch_transactions_retried
@fetch_transactions_retried = true
fetch_transactions
end