1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Synth error handling

This commit is contained in:
Josh Pigford 2024-11-25 14:53:09 -06:00
parent 955f211fe0
commit fd6a0a12b4
4 changed files with 45 additions and 5 deletions

View file

@ -0,0 +1,5 @@
class Issue::SynthLimitExceeded < Issue
def title
"Synth API Credit Limit Exceeded"
end
end

View file

@ -194,11 +194,18 @@ class Provider::Synth
end
def build_error(response)
Provider::Base::ProviderError.new(<<~ERROR)
Failed to fetch data from #{self.class}
Status: #{response.status}
Body: #{response.body.inspect}
ERROR
if response.status == 402
Provider::Base::ProviderError.new(<<~ERROR)
Your Synth API credit limit has been exceeded
Please visit your Synth billing settings to upgrade your plan or wait for your credits to reset.
ERROR
else
Provider::Base::ProviderError.new(<<~ERROR)
Failed to fetch data from #{self.class}
Status: #{response.status}
Body: #{response.body.inspect}
ERROR
end
end
def fetch_page(url, page, params = {})

View file

@ -0,0 +1,13 @@
<div class="space-y-4">
<p>Your Synth API credit limit has been exceeded.</p>
<p>You can:</p>
<ul class="list-disc pl-4 space-y-2">
<li>Wait for your API credits to reset at the start of your next billing cycle or upgrade your Synth plan</li>
<li>
<%= link_to "View your current usage and upgrade your plan",
"https://dashboard.synthfinance.com/settings",
class: "text-blue-500 hover:text-blue-700" %>
</li>
</ul>
</div>

View file

@ -0,0 +1,15 @@
<%= content_for :title, @issue.title %>
<%= content_for :description do %>
<%= render "issue/synth_limit_exceeded" %>
<% end %>
<%= content_for :action do %>
<div class="space-y-4">
<% if self_hosted? %>
<%= link_to "View Usage & Upgrade", "https://dashboard.synthfinance.com/settings", class: "btn btn--primary" %>
<% else %>
<p>Please contact the Maybe team for assistance.</p>
<% end %>
</div>
<% end %>