Exception: AtlasRb::CompilationError

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 Compilation (Set) write with a 422 carrying a machine-readable error discriminator — a blank title on create/update (invalid_record), or a membership add whose noid does not resolve to the expected type (a Community where a Collection is required, an unknown id, a Collection where a Work is required).

The Compilation sibling of LinkedMemberError; same shape, same rationale (the binding's ["compilation"] unwrap would otherwise discard the envelope on a non-2xx).

rescue AtlasRb::CompilationError => e
flash.now[:alert] = e.message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CompilationError.

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.



162
163
164
165
166
# File 'lib/atlas_rb/errors.rb', line 162

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 (currently "invalid_record").

Returns:

  • (String, nil)

    the machine-readable error code from the envelope (currently "invalid_record").



153
154
155
# File 'lib/atlas_rb/errors.rb', line 153

def code
  @code
end

#resource_idString? (readonly)

Returns the rejected resource's ID, from the envelope (may be nil — validation envelopes don't always carry one).

Returns:

  • (String, nil)

    the rejected resource's ID, from the envelope (may be nil — validation envelopes don't always carry one).



157
158
159
# File 'lib/atlas_rb/errors.rb', line 157

def resource_id
  @resource_id
end