Exception: Insika::BudgetExceeded

Inherits:
Error
  • Object
show all
Defined in:
lib/insika/errors.rb

Overview

The hard budget refused the turn (WS2): the (tenant, agent) spend in the window already met its cap BEFORE the turn ran. A typed, retryable failure — the envelope reads budget_exceeded + retry_after (seconds until the window rolls) — never a silent drop. window is :daily | :monthly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, window: nil, retry_after: nil) ⇒ BudgetExceeded

Returns a new instance of BudgetExceeded.



62
63
64
65
66
# File 'lib/insika/errors.rb', line 62

def initialize(message = nil, window: nil, retry_after: nil)
  @window = window
  @retry_after = retry_after
  super(message || "budget exceeded (#{window})")
end

Instance Attribute Details

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



60
61
62
# File 'lib/insika/errors.rb', line 60

def retry_after
  @retry_after
end

#windowObject (readonly)

Returns the value of attribute window.



60
61
62
# File 'lib/insika/errors.rb', line 60

def window
  @window
end

Instance Method Details

#classificationObject



68
69
70
# File 'lib/insika/errors.rb', line 68

def classification
  { kind: :budget_exceeded, retryable: true, retry_after: retry_after }.compact
end