Exception: MisarReach::UpgradeRequiredError
- Defined in:
- lib/misar_reach/errors.rb
Overview
429 with upgrade: true — the workspace plan must be upgraded to proceed.
A counted plan cap was hit.
MisarReach answers 402 with upgrade: true when a cap is reached and names
the offending counter. Retrying cannot help until the cap resets or the
plan changes.
Distinct from the 503 retry: true the server sends when it could not
check the quota: that one is retried, so "we do not know" is never
mistaken for "you are over your limit".
Constant Summary collapse
- APP_ORIGIN =
"https://misarreach.com".freeze
Instance Attribute Summary collapse
-
#current ⇒ Integer?
readonly
Usage against that cap when the call was refused.
-
#feature ⇒ String?
readonly
The counter that was exhausted, e.g.
-
#limit ⇒ Integer?
readonly
The cap on the current plan.
-
#upgrade_url ⇒ String?
readonly
Absolute URL to the billing page.
Attributes inherited from ApiError
#body, #code, #retry_after, #status
Instance Method Summary collapse
-
#initialize(message = "Upgrade required", **opts) ⇒ UpgradeRequiredError
constructor
A new instance of UpgradeRequiredError.
Constructor Details
#initialize(message = "Upgrade required", **opts) ⇒ UpgradeRequiredError
Returns a new instance of UpgradeRequiredError.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/misar_reach/errors.rb', line 62 def initialize( = "Upgrade required", **opts) body = opts[:body] || {} @feature = body["feature"] @limit = body["limit"] @current = body["current"] # The server sends an app-relative path; make it linkable. url = body["upgrade_url"] @upgrade_url = if url.nil? || url.start_with?("http://", "https://") url else APP_ORIGIN + (url.start_with?("/") ? url : "/#{url}") end super(opts[:status] || 402, , code: opts[:code] || "upgrade_required", **opts.reject { |k, _| %i[code status].include?(k) }) end |
Instance Attribute Details
#current ⇒ Integer? (readonly)
Returns usage against that cap when the call was refused.
58 59 60 |
# File 'lib/misar_reach/errors.rb', line 58 def current @current end |
#feature ⇒ String? (readonly)
Returns the counter that was exhausted, e.g. "lead_searches".
54 55 56 |
# File 'lib/misar_reach/errors.rb', line 54 def feature @feature end |
#limit ⇒ Integer? (readonly)
Returns the cap on the current plan.
56 57 58 |
# File 'lib/misar_reach/errors.rb', line 56 def limit @limit end |
#upgrade_url ⇒ String? (readonly)
Returns absolute URL to the billing page.
60 61 62 |
# File 'lib/misar_reach/errors.rb', line 60 def upgrade_url @upgrade_url end |