Exception: Doyoubuzz::Showcase::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/doyoubuzz/showcase/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, response_body) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/doyoubuzz/showcase/error.rb', line 6

def initialize(status, response_body)
  # Try to extract a meaningful message from the error
  message = begin
    parsed_body = JSON.parse(response_body)
    parsed_body['error']['message']
  rescue  => e
    response_body
  end

  super(message)
  @status = status
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/doyoubuzz/showcase/error.rb', line 4

def status
  @status
end

Instance Method Details

#inspectObject



19
20
21
# File 'lib/doyoubuzz/showcase/error.rb', line 19

def inspect
  "#<Doyoubuzz::Showcase::Error #{status}: #{message}>"
end