Exception: Whatsapp::BridgeError

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

Overview

Raised when the Node bridge returns an HTTP error response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = "Bridge returned an error", status_code: nil, body: nil) ⇒ BridgeError

Returns a new instance of BridgeError.

Parameters:

  • msg (String) (defaults to: "Bridge returned an error")

    error message

  • status_code (Integer, nil) (defaults to: nil)

    HTTP status code

  • body (Hash, nil) (defaults to: nil)

    parsed response body



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

def initialize(msg = "Bridge returned an error", status_code: nil, body: nil)
  @status_code = status_code
  @body = body
  super(msg)
end

Instance Attribute Details

#bodyHash? (readonly)

Returns parsed response body.

Returns:

  • (Hash, nil)

    parsed response body



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/whatsapp/errors.rb', line 27

class BridgeError < Error
  attr_reader :status_code, :body

  # @param msg [String] error message
  # @param status_code [Integer, nil] HTTP status code
  # @param body [Hash, nil] parsed response body
  def initialize(msg = "Bridge returned an error", status_code: nil, body: nil)
    @status_code = status_code
    @body = body
    super(msg)
  end
end

#status_codeInteger? (readonly)

Returns HTTP status code from the bridge.

Returns:

  • (Integer, nil)

    HTTP status code from the bridge



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/whatsapp/errors.rb', line 27

class BridgeError < Error
  attr_reader :status_code, :body

  # @param msg [String] error message
  # @param status_code [Integer, nil] HTTP status code
  # @param body [Hash, nil] parsed response body
  def initialize(msg = "Bridge returned an error", status_code: nil, body: nil)
    @status_code = status_code
    @body = body
    super(msg)
  end
end