Exception: AtlasRb::DerivativePermissionsError

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 per-tier derivative-visibility policy (PATCH /works/:id/derivative_permissions) with a 422 carrying a machine-readable error discriminator — tier_exceeds_resource (a tier more visible than its Work), tier_ordering_violation (visibility not narrowing as resolution grows), or unknown_tier.

The derivative-permissions sibling of ReparentError / LinkedMemberError; same shape, same rationale (the binding's ["work"] unwrap would otherwise discard the envelope on the 422). Atlas rejects before persisting.

rescue AtlasRb::DerivativePermissionsError => e
flash.now[:alert] = t("derivative_permissions.errors.#{e.code}", default: e.message)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DerivativePermissionsError.

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 Work's ID.



197
198
199
200
201
# File 'lib/atlas_rb/errors.rb', line 197

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.



189
190
191
# File 'lib/atlas_rb/errors.rb', line 189

def code
  @code
end

#resource_idString? (readonly)

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

Returns:

  • (String, nil)

    the rejected Work's ID, from the envelope.



192
193
194
# File 'lib/atlas_rb/errors.rb', line 192

def resource_id
  @resource_id
end