Exception: AtlasRb::ReparentError

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

Overview

Note:

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.#{e.code}", default: e.message)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code: nil, resource_id: nil) ⇒ ReparentError



69
70
71
72
73
# File 'lib/atlas_rb/errors.rb', line 69

def initialize(message, code: nil, resource_id: nil)
  super(message)
  @code = code
  @resource_id = resource_id
end

Instance Attribute Details

#codeString? (readonly)



61
62
63
# File 'lib/atlas_rb/errors.rb', line 61

def code
  @code
end

#resource_idString? (readonly)



64
65
66
# File 'lib/atlas_rb/errors.rb', line 64

def resource_id
  @resource_id
end