Exception: FreebaseAPI::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/freebase_api/exceptions.rb

Overview

A class for returning errors from the Freebase API

Direct Known Subclasses

NetError, ServiceError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
# File 'lib/freebase_api/exceptions.rb', line 6

def initialize(params)
  FreebaseAPI.logger.error("#{params['message']} (#{params['code']})")
  self.code = params['code']
  self.message = params['message']
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/freebase_api/exceptions.rb', line 4

def code
  @code
end

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/freebase_api/exceptions.rb', line 4

def errors
  @errors
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/freebase_api/exceptions.rb', line 4

def message
  @message
end

Instance Method Details

#to_sObject



12
13
14
# File 'lib/freebase_api/exceptions.rb', line 12

def to_s
  "#{self.message} (#{self.code})"
end