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.



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

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").



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

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).



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

def resource_id
  @resource_id
end