Exception: AtlasRb::PermissionsError
- Defined in:
- lib/atlas_rb/errors.rb
Overview
Keyed on the envelope's error code, not the request path, so other
422s on the same endpoint (e.g. tombstone's has_live_children) pass
through untouched.
Raised when Atlas refuses an ACL write on a resource
(PATCH /{works,collections,communities}/:id with metadata[permissions])
because it breaks a rights invariant. Today the one code is
visibility_exceeds_parent: a resource may be no more visible than its
structural container, so opening a Work to public inside a restricted
Collection is refused (the fix is to widen the container).
This is NOT an authorization failure — the caller may well hold full edit
rights on the resource, and a depositor choosing "Public" on their own item
under a private collection trips it in ordinary use. Without the typed
error the binding's ["collection"] / ["work"] unwrap returns an envelope
the caller reads as success, so the user's visibility edit is silently
discarded.
rescue AtlasRb::PermissionsError => e
flash.now[:alert] = t("permissions.errors.#{e.code}", default: e.message)
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
The machine-readable error code from the envelope, suitable for keying an i18n map.
-
#resource_id ⇒ String?
readonly
The rejected resource's ID, from the envelope.
Instance Method Summary collapse
-
#initialize(message, code: nil, resource_id: nil) ⇒ PermissionsError
constructor
A new instance of PermissionsError.
Constructor Details
#initialize(message, code: nil, resource_id: nil) ⇒ PermissionsError
Returns a new instance of PermissionsError.
235 236 237 238 239 |
# File 'lib/atlas_rb/errors.rb', line 235 def initialize(, code: nil, resource_id: nil) super() @code = code @resource_id = resource_id end |
Instance Attribute Details
#code ⇒ String? (readonly)
Returns the machine-readable error code from the envelope, suitable for keying an i18n map.
227 228 229 |
# File 'lib/atlas_rb/errors.rb', line 227 def code @code end |
#resource_id ⇒ String? (readonly)
Returns the rejected resource's ID, from the envelope.
230 231 232 |
# File 'lib/atlas_rb/errors.rb', line 230 def resource_id @resource_id end |