Exception: ApiWrapperFor8x8::ResponseError

Inherits:
Exception
  • Object
show all
Defined in:
lib/ApiWrapperFor8x8/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, message = nil) ⇒ ResponseError

Returns a new instance of ResponseError.



5
6
7
8
9
# File 'lib/ApiWrapperFor8x8/error.rb', line 5

def initialize(response, message=nil)
  self.set_backtrace(caller[1..-1]) if self.backtrace.nil?
  @response = response
  super((message || @response.message))
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/ApiWrapperFor8x8/error.rb', line 3

def response
  @response
end

Instance Method Details

#codeObject



11
12
13
# File 'lib/ApiWrapperFor8x8/error.rb', line 11

def code
  @response.code
end

#common_solutionsObject



15
16
17
18
19
20
21
# File 'lib/ApiWrapperFor8x8/error.rb', line 15

def common_solutions
  if @response.code.to_i == 401
    "Check your credentials and make sure they are correct and not expired"
  elsif @response.code.to_i >= 500 && @response.code.to_i < 600
    "Check the format of your json"
  end
end

#detailed_messageObject



23
24
25
26
27
# File 'lib/ApiWrapperFor8x8/error.rb', line 23

def detailed_message
  if @response.is_a? Hash
    @response[:error][:message] if @response[:error]
  end
end