Exception: AtlasRb::ReparentError
- Defined in:
- lib/atlas_rb/errors.rb
Overview
Authorization failures surface as ForbiddenError (HTTP 403), not this — even on a re-parent path.
Raised when Atlas rejects a re-parent (PATCH /<type>/:id/parent) with a
structural 422 carrying a machine-readable error discriminator —
tombstoned_node, tombstoned_parent, parent_required,
invalid_parent_type, cycle, or parent_not_found.
Mirrors StaleResourceError: a narrow translation of one wire signal
callers need to discriminate on. Without it the binding's ["collection"]
/ ["work"] / ["community"] unwrap silently returns nil on a 422,
discarding Atlas's error/message and leaving the caller unable to tell
an invalid move from a not-found from a forbidden one.
Callers key on #code for specific messaging, falling back to #message:
rescue AtlasRb::ReparentError => e flash.now[:alert] = t("reparent.errors.#ee.code", default: e.message)
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
The machine-readable error code from the envelope (e.g.
"cycle"), 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) ⇒ ReparentError
constructor
A new instance of ReparentError.
Constructor Details
#initialize(message, code: nil, resource_id: nil) ⇒ ReparentError
Returns a new instance of ReparentError.
69 70 71 72 73 |
# File 'lib/atlas_rb/errors.rb', line 69 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
(e.g. "cycle"), suitable for keying an i18n map.
61 62 63 |
# File 'lib/atlas_rb/errors.rb', line 61 def code @code end |
#resource_id ⇒ String? (readonly)
Returns the rejected resource's ID, from the envelope.
64 65 66 |
# File 'lib/atlas_rb/errors.rb', line 64 def resource_id @resource_id end |