Exception: FBUtilError

Inherits:
Exception
  • Object
show all
Defined in:
lib/fb_util/fb_util_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code, body) ⇒ FBUtilError

Returns a new instance of FBUtilError.



4
5
6
7
8
9
10
11
12
# File 'lib/fb_util/fb_util_error.rb', line 4

def initialize(error_code, body)
  @error_code = error_code
  @body = body
  begin
    @object = JSON.parse(body)
  rescue JSON::ParserError
    @object = {"error" => {"message" => "Response was not valid json. See the body for more information."}}
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/fb_util/fb_util_error.rb', line 2

def body
  @body
end

#error_codeObject

Returns the value of attribute error_code.



2
3
4
# File 'lib/fb_util/fb_util_error.rb', line 2

def error_code
  @error_code
end

#objectObject

Returns the value of attribute object.



2
3
4
# File 'lib/fb_util/fb_util_error.rb', line 2

def object
  @object
end

Instance Method Details

#to_sObject



14
15
16
# File 'lib/fb_util/fb_util_error.rb', line 14

def to_s
  "Response code: #{error_code} => #{body}"
end