diff --git a/app/models/issue/synth_limit_exceeded.rb b/app/models/issue/synth_limit_exceeded.rb new file mode 100644 index 00000000..01a8becb --- /dev/null +++ b/app/models/issue/synth_limit_exceeded.rb @@ -0,0 +1,5 @@ +class Issue::SynthLimitExceeded < Issue + def title + "Synth API Credit Limit Exceeded" + end +end diff --git a/app/models/provider/synth.rb b/app/models/provider/synth.rb index 8247ab34..d8fde92d 100644 --- a/app/models/provider/synth.rb +++ b/app/models/provider/synth.rb @@ -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 = {}) diff --git a/app/views/issue/_synth_limit_exceeded.html.erb b/app/views/issue/_synth_limit_exceeded.html.erb new file mode 100644 index 00000000..c91922b1 --- /dev/null +++ b/app/views/issue/_synth_limit_exceeded.html.erb @@ -0,0 +1,13 @@ +
Your Synth API credit limit has been exceeded.
+ +You can:
+Please contact the Maybe team for assistance.
+ <% end %> +