mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Implement error handling and logging for sparkline and series methods
- Added rescue blocks to handle exceptions in the Accounts and AccountableSparklines controllers, logging errors and rendering error partials. - Enhanced error handling in the Account::Chartable and Balance::ChartSeriesBuilder models, logging specific error messages for series generation failures. - Updated the accounts view to include a timeout for Turbo frame loading. - Added a test to ensure graceful handling of sparkline errors in the AccountsController. In reference to bug #2315
This commit is contained in:
parent
3cc88f3e98
commit
6f67827f14
9 changed files with 113 additions and 8 deletions
|
@ -29,5 +29,15 @@ module Account::Chartable
|
|||
Rails.cache.fetch(cache_key) do
|
||||
balance_series
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "Sparkline series error for account #{id}: #{e.message}"
|
||||
# Return empty series as fallback
|
||||
Series.new(
|
||||
start_date: 30.days.ago.to_date,
|
||||
end_date: Date.current,
|
||||
interval: "1 day",
|
||||
values: [],
|
||||
favorable_direction: favorable_direction
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,14 +9,23 @@ class Balance::ChartSeriesBuilder
|
|||
|
||||
def balance_series
|
||||
build_series_for(:balance)
|
||||
rescue => e
|
||||
Rails.logger.error "Balance series error: #{e.message} for accounts #{@account_ids}"
|
||||
raise
|
||||
end
|
||||
|
||||
def cash_balance_series
|
||||
build_series_for(:cash_balance)
|
||||
rescue => e
|
||||
Rails.logger.error "Cash balance series error: #{e.message} for accounts #{@account_ids}"
|
||||
raise
|
||||
end
|
||||
|
||||
def holdings_balance_series
|
||||
build_series_for(:holdings_balance)
|
||||
rescue => e
|
||||
Rails.logger.error "Holdings balance series error: #{e.message} for accounts #{@account_ids}"
|
||||
raise
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -61,6 +70,9 @@ class Balance::ChartSeriesBuilder
|
|||
sign_multiplier: sign_multiplier
|
||||
}
|
||||
])
|
||||
rescue => e
|
||||
Rails.logger.error "Query data error: #{e.message} for accounts #{account_ids}, period #{period.start_date} to #{period.end_date}"
|
||||
raise
|
||||
end
|
||||
|
||||
# Since the query aggregates the *net* of assets - liabilities, this means that if we're looking at
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue