Exception: Textus::WriteForbidden

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(k, z, writers: nil) ⇒ WriteForbidden

Returns a new instance of WriteForbidden.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/textus/errors.rb', line 87

def initialize(k, z, writers: nil)
  writers_str =
    if writers && !writers.empty?
      writers.join(", ")
    else
      "the role(s) listed in the manifest 'writable_by:'"
    end
  details = { "key" => k, "zone" => z }
  details["writers"] = writers if writers
  super(
    "write_forbidden",
    "zone '#{z}' is not agent-writable for key '#{k}'",
    details: details,
    hint: "this zone is writable by #{writers_str}; pass --as=<role>",
  )
end