Exception: Turbocable::PublishError

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

Overview

Raised when a publish fails after all retries have been exhausted. Wraps the underlying NATS error and preserves diagnostic metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, subject:, attempts:, cause: nil) ⇒ PublishError

Returns a new instance of PublishError.

Parameters:

  • message (String)
  • subject (String)
  • attempts (Integer)
  • cause (Exception, nil) (defaults to: nil)


52
53
54
55
56
57
# File 'lib/turbocable/errors.rb', line 52

def initialize(message, subject:, attempts:, cause: nil)
  super(message)
  @subject = subject
  @attempts = attempts
  @cause = cause
end

Instance Attribute Details

#attemptsInteger (readonly)

Returns the number of publish attempts made (1 = no retries).

Returns:

  • (Integer)

    the number of publish attempts made (1 = no retries)



46
47
48
# File 'lib/turbocable/errors.rb', line 46

def attempts
  @attempts
end

#subjectString (readonly)

Returns the NATS subject that was targeted.

Returns:

  • (String)

    the NATS subject that was targeted



43
44
45
# File 'lib/turbocable/errors.rb', line 43

def subject
  @subject
end

Instance Method Details

#causeException?

Returns the underlying exception from the final attempt.

Returns:

  • (Exception, nil)

    the underlying exception from the final attempt



60
61
62
# File 'lib/turbocable/errors.rb', line 60

def cause
  @cause || super
end