Exception: SemaphoreClient::Exceptions::ResponseError

Inherits:
Base
  • Object
show all
Defined in:
lib/semaphore_client/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ ResponseError

Returns a new instance of ResponseError.



12
13
14
15
16
# File 'lib/semaphore_client/exceptions.rb', line 12

def initialize(env)
  @env = env

  super(message)
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



10
11
12
# File 'lib/semaphore_client/exceptions.rb', line 10

def env
  @env
end

Instance Method Details

#bodyObject



26
27
28
# File 'lib/semaphore_client/exceptions.rb', line 26

def body
  JSON.parse(@env[:body])
end

#codeObject



18
19
20
# File 'lib/semaphore_client/exceptions.rb', line 18

def code
  @env[:status]
end

#messageObject



22
23
24
# File 'lib/semaphore_client/exceptions.rb', line 22

def message
  body["message"] if body.is_a?(Hash)
end