Exception: AtlasRb::LinkedMemberError

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

Overview

Note:

Authorization failures surface as ForbiddenError (HTTP 403).

Raised when Atlas rejects a linked-member write (POST / DELETE /works/:id/linked_members) with a 422 carrying a machine-readable error discriminator. The linked-member sibling of ReparentError; same shape, same rationale (the binding would otherwise discard the envelope on a non-2xx).

rescue AtlasRb::LinkedMemberError => e flash.now[:alert] = t("linked_member.errors.#ee.code", default: e.message)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LinkedMemberError.

Parameters:

  • message (String)

    human-readable rejection description.

  • code (String, nil) (defaults to: nil)

    the envelope's error discriminator.

  • resource_id (String, nil) (defaults to: nil)

    the rejected resource's ID.



97
98
99
100
101
# File 'lib/atlas_rb/errors.rb', line 97

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

Instance Attribute Details

#codeString? (readonly)

Returns the machine-readable error code from the envelope, suitable for keying an i18n map.

Returns:

  • (String, nil)

    the machine-readable error code from the envelope, suitable for keying an i18n map.



89
90
91
# File 'lib/atlas_rb/errors.rb', line 89

def code
  @code
end

#resource_idString? (readonly)

Returns the rejected resource's ID, from the envelope.

Returns:

  • (String, nil)

    the rejected resource's ID, from the envelope.



92
93
94
# File 'lib/atlas_rb/errors.rb', line 92

def resource_id
  @resource_id
end