Exception: Textus::GuardFailed

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

Instance Attribute Summary

Attributes inherited from Error

#code, #details, #exit_code, #hint

Instance Method Summary collapse

Methods inherited from Error

#to_envelope

Constructor Details

#initialize(failed) ⇒ GuardFailed

Returns a new instance of GuardFailed.



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/textus/errors.rb', line 190

def initialize(failed)
  # failed: [[predicate_name, reason], ...]
  rows = failed.map { |name, reason| { "predicate" => name, "reason" => reason } }
  names = failed.map(&:first)
  super(
    "guard_failed",
    "guard refused crossing: #{failed.map { |n, r| "#{n} (#{r})" }.join("; ")}",
    details: { "failed" => rows },
    hint: "run 'textus policy explain <key> --output=json' to see the full guard; " \
          "unmet: #{names.join(", ")}",
  )
end