Exception: Aeternitas::Guard::GuardIsLocked

Inherits:
StandardError
  • Object
show all
Defined in:
lib/aeternitas/guard.rb

Overview

Custom error class thrown when the lock can not be acquired

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_id, timeout, reason = nil) ⇒ GuardIsLocked

Returns a new instance of GuardIsLocked.



158
159
160
161
162
163
# File 'lib/aeternitas/guard.rb', line 158

def initialize(resource_id, timeout, reason = nil)
  msg = "Resource '#{resource_id}' is locked until #{timeout}."
  msg += " Reason: #{reason}" if reason
  super(msg)
  @timeout = timeout
end

Instance Attribute Details

#timeoutDateTime (readonly)

Returns the locks current timeout.

Returns:

  • (DateTime)

    the locks current timeout



155
156
157
158
159
160
161
162
163
164
# File 'lib/aeternitas/guard.rb', line 155

class GuardIsLocked < StandardError
  attr_reader :timeout

  def initialize(resource_id, timeout, reason = nil)
    msg = "Resource '#{resource_id}' is locked until #{timeout}."
    msg += " Reason: #{reason}" if reason
    super(msg)
    @timeout = timeout
  end
end