Exception: Baidu::Errors::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/baidu/errors/error.rb

Direct Known Subclasses

AuthError, ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, code = nil, response = nil) ⇒ Error

Returns a new instance of Error.



6
7
8
# File 'lib/baidu/errors/error.rb', line 6

def initialize(msg, code=nil, response=nil)
  @msg, @code, @response = msg, code, response
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



4
5
6
# File 'lib/baidu/errors/error.rb', line 4

def code
  @code
end

#msgObject (readonly)

Returns the value of attribute msg.



4
5
6
# File 'lib/baidu/errors/error.rb', line 4

def msg
  @msg
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/baidu/errors/error.rb', line 4

def response
  @response
end

Instance Method Details

#to_sObject



10
11
12
13
14
15
# File 'lib/baidu/errors/error.rb', line 10

def to_s
  arr = %w[Error]
  arr << "code: #{code}" unless code.nil?
  arr << "msg: #{msg}"   unless msg.nil?
  arr.join(' ')
end