Exception: MailCapture::TimeoutError

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

Overview

Raised by wait_for when no email arrives before the timeout.

rescue MailCapture::TimeoutError => e
  puts "Waited #{e.waited_seconds}s for tag: #{e.tag}"
end

Instance Attribute Summary collapse

Attributes inherited from Error

#code

Instance Method Summary collapse

Constructor Details

#initialize(tag:, waited_seconds:, hint: nil) ⇒ TimeoutError

Returns a new instance of TimeoutError.



42
43
44
45
46
47
48
# File 'lib/mailcapture/errors.rb', line 42

def initialize(tag:, waited_seconds:, hint: nil)
  @tag = tag
  @waited_seconds = waited_seconds
  message = "No email arrived for tag #{tag.inspect} within #{waited_seconds.to_i}s."
  message += " #{hint}" if hint
  super(message, code: 'TIMEOUT')
end

Instance Attribute Details

#tagString (readonly)

Returns the tag that was being waited on.

Returns:

  • (String)

    the tag that was being waited on



38
39
40
# File 'lib/mailcapture/errors.rb', line 38

def tag
  @tag
end

#waited_secondsNumeric (readonly)

Returns seconds elapsed before giving up.

Returns:

  • (Numeric)

    seconds elapsed before giving up



40
41
42
# File 'lib/mailcapture/errors.rb', line 40

def waited_seconds
  @waited_seconds
end