1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +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:
Josh Pigford 2025-05-26 20:05:16 -05:00
parent 3cc88f3e98
commit 6f67827f14
9 changed files with 113 additions and 8 deletions

View file

@ -0,0 +1,8 @@
<%= turbo_frame_tag "#{params[:accountable_type]}_sparkline" do %>
<div class="flex items-center justify-end gap-1">
<div class="w-8 h-3 flex items-center justify-center">
<%= icon("alert-triangle", size: "sm", class: "text-warning") %>
</div>
<p class="font-mono text-right text-xs text-warning">Error</p>
</div>
<% end %>

View file

@ -14,7 +14,7 @@
</div>
<% else %>
<%= tag.p format_money(account_group.total_money), class: "text-sm font-medium text-primary" %>
<%= turbo_frame_tag "#{account_group.key}_sparkline", src: accountable_sparkline_path(account_group.key), loading: "lazy" do %>
<%= turbo_frame_tag "#{account_group.key}_sparkline", src: accountable_sparkline_path(account_group.key), loading: "lazy", data: { controller: "turbo-frame-timeout", turbo_frame_timeout_timeout_value: 10000 } do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>
@ -50,7 +50,7 @@
<% else %>
<div class="ml-auto text-right grow h-10">
<%= tag.p format_money(account.balance_money), class: "text-sm font-medium text-primary whitespace-nowrap" %>
<%= turbo_frame_tag dom_id(account, :sparkline), src: sparkline_account_path(account), loading: "lazy" do %>
<%= turbo_frame_tag dom_id(account, :sparkline), src: sparkline_account_path(account), loading: "lazy", data: { controller: "turbo-frame-timeout", turbo_frame_timeout_timeout_value: 10000 } do %>
<div class="flex items-center w-8 h-4 ml-auto">
<div class="w-6 h-px bg-loader"></div>
</div>

View file

@ -0,0 +1,8 @@
<%= turbo_frame_tag dom_id(@account, :sparkline) do %>
<div class="flex items-center justify-end gap-1">
<div class="w-8 h-5 flex items-center justify-center">
<%= icon("alert-triangle", size: "sm", class: "text-warning") %>
</div>
<p class="font-mono text-right text-xs text-warning">Error</p>
</div>
<% end %>