Exception: Whatsapp::MessageFailed

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

Overview

Raised when a message send operation fails.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to:, reason: nil) ⇒ MessageFailed

Returns a new instance of MessageFailed.

Parameters:

  • to (String)

    recipient phone number

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

    failure reason



58
59
60
61
62
# File 'lib/whatsapp/errors.rb', line 58

def initialize(to:, reason: nil)
  @to = to
  @reason = reason
  super("Failed to send message to #{to}: #{reason}")
end

Instance Attribute Details

#reasonString? (readonly)

Returns failure reason.

Returns:

  • (String, nil)

    failure reason



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/whatsapp/errors.rb', line 53

class MessageFailed < Error
  attr_reader :to, :reason

  # @param to [String] recipient phone number
  # @param reason [String, nil] failure reason
  def initialize(to:, reason: nil)
    @to = to
    @reason = reason
    super("Failed to send message to #{to}: #{reason}")
  end
end

#toString (readonly)

Returns recipient phone number.

Returns:

  • (String)

    recipient phone number



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/whatsapp/errors.rb', line 53

class MessageFailed < Error
  attr_reader :to, :reason

  # @param to [String] recipient phone number
  # @param reason [String, nil] failure reason
  def initialize(to:, reason: nil)
    @to = to
    @reason = reason
    super("Failed to send message to #{to}: #{reason}")
  end
end