Exception: AtlasRb::WorkAssociationError
- Defined in:
- lib/atlas_rb/errors.rb
Overview
Authorization failures surface as ForbiddenError (HTTP 403) — asserting an association is admin / devolved-admin only.
Raised when Atlas rejects a Work-association write
(POST / DELETE /works/:id/associations...) with a 422 carrying a
machine-readable error discriminator — invalid_type (not one of the
five predicates), target_not_found, invalid_target_type (the target is
not a Work), self_association, tombstoned_work, or tombstoned_target.
The association sibling of LinkedMemberError; same shape, same rationale (the binding would otherwise discard the envelope on a non-2xx).
rescue AtlasRb::WorkAssociationError => e
flash.now[:alert] = t("associations.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 Work's ID, from the envelope.
Instance Method Summary collapse
-
#initialize(message, code: nil, resource_id: nil) ⇒ WorkAssociationError
constructor
A new instance of WorkAssociationError.
Constructor Details
#initialize(message, code: nil, resource_id: nil) ⇒ WorkAssociationError
Returns a new instance of WorkAssociationError.
129 130 131 132 133 |
# File 'lib/atlas_rb/errors.rb', line 129 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.
121 122 123 |
# File 'lib/atlas_rb/errors.rb', line 121 def code @code end |
#resource_id ⇒ String? (readonly)
Returns the rejected Work's ID, from the envelope.
124 125 126 |
# File 'lib/atlas_rb/errors.rb', line 124 def resource_id @resource_id end |