Exception: AtlasRb::StaleResourceError

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

Overview

Raised when Atlas responds with HTTP 409 + error: "stale_resource", indicating an optimistic-lock conflict that either (a) exhausted Atlas's internal retry budget for a retry-safe action, or (b) hit a retry-unsafe action and surfaced immediately.

Callers (typically ActiveJob subclasses in Cerberus) handle this via:

retry_on AtlasRb::StaleResourceError, attempts: 5, wait: :polynomially_longer

The exception carries the resource_id and action from Atlas's envelope so failure logs are useful without needing the full HTTP response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, resource_id: nil, action: nil) ⇒ StaleResourceError

Returns a new instance of StaleResourceError.

Parameters:

  • message (String)

    human-readable conflict description.

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

    the conflicted resource's ID.

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

    the controller action that conflicted.



33
34
35
36
37
# File 'lib/atlas_rb/errors.rb', line 33

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

Instance Attribute Details

#actionString? (readonly)

Returns the controller action that conflicted, from the envelope (e.g. "update_thumbnails").

Returns:

  • (String, nil)

    the controller action that conflicted, from the envelope (e.g. "update_thumbnails").



28
29
30
# File 'lib/atlas_rb/errors.rb', line 28

def action
  @action
end

#resource_idString? (readonly)

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

Returns:

  • (String, nil)

    the conflicted resource's ID, from the envelope.



24
25
26
# File 'lib/atlas_rb/errors.rb', line 24

def resource_id
  @resource_id
end