Exception: AtlasRb::WorkAssociationError

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

Overview

Note:

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

Instance Method Summary collapse

Constructor Details

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



129
130
131
132
133
# File 'lib/atlas_rb/errors.rb', line 129

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

Instance Attribute Details

#codeString? (readonly)



121
122
123
# File 'lib/atlas_rb/errors.rb', line 121

def code
  @code
end

#resource_idString? (readonly)



124
125
126
# File 'lib/atlas_rb/errors.rb', line 124

def resource_id
  @resource_id
end