Exception: Portage::Ucp::PolicyViolationError

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

Overview

Raised by PolicyGuard.check! (docs/plans/agentic-payments.md Phase 2) when a payment-completing dispatch fails a locally-configured guard — spend cap, velocity limit, merchant allowlist, or per-token scope. reason is a stable snake_case symbol (not just the message) so a caller can branch on why without parsing prose, matching OutOfStockError/ConflictError's freeform-error-code convention above. decision carries the same shape PolicyGuard.check! returns on success, so Dispatcher can persist "blocked, here's why" onto the Phase 0 transaction record the same way it persists a passing decision.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, reason:, decision:) ⇒ PolicyViolationError

Returns a new instance of PolicyViolationError.



68
69
70
71
72
# File 'lib/portage/ucp/errors.rb', line 68

def initialize(message, reason:, decision:)
  super(message)
  @reason = reason
  @decision = decision
end

Instance Attribute Details

#decision ⇒ Object (readonly)

Returns the value of attribute decision.



66
67
68
# File 'lib/portage/ucp/errors.rb', line 66

def decision
  @decision
end

#reason ⇒ Object (readonly)

Returns the value of attribute reason.



66
67
68
# File 'lib/portage/ucp/errors.rb', line 66

def reason
  @reason
end