diff --git a/app/controllers/services/lightning_controller.rb b/app/controllers/services/lightning_controller.rb index 4dd9607..9e39feb 100644 --- a/app/controllers/services/lightning_controller.rb +++ b/app/controllers/services/lightning_controller.rb @@ -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 diff --git a/app/services/lndhub.rb b/app/services/lndhub.rb index 9febebf..4c8ad66 100644 --- a/app/services/lndhub.rb +++ b/app/services/lndhub.rb @@ -12,12 +12,7 @@ class Lndhub end res = Faraday.post "#{@base_url}/#{endpoint}", payload.to_json, headers - - if res.status != 200 - Rails.logger.error "[lndhub] API request failed:" - Rails.logger.error res.body - #TODO add some kind of exception tracking/notifications - end + log_error(res) if res.status != 200 JSON.parse(res.body) end @@ -68,4 +63,13 @@ class Lndhub invoice["payment_request"] end + + def log_error(res) + Rails.logger.error "[lndhub] API request failed:" + Rails.logger.error res.body + + if Setting.sentry_enabled? + Sentry.capture_message("Lndhub API request failed: #{res.body}") + end + end end