Exception: RestMan::Exception

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/restman/exception.rb

Overview

:include: _doc/lib/restman/exception.rdoc

Direct Known Subclasses

ExceptionWithResponse, ServerBrokeConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil, initial_response_code = nil) ⇒ Exception

Returns a new instance of Exception.



8
9
10
11
12
# File 'lib/restman/exception.rb', line 8

def initialize response = nil, initial_response_code = nil
  @response = response
  @message = nil
  @initial_response_code = initial_response_code
end

Instance Attribute Details

#messageObject



35
36
37
# File 'lib/restman/exception.rb', line 35

def message
  @message || default_message
end

#original_exceptionObject

Returns the value of attribute original_exception.



5
6
7
# File 'lib/restman/exception.rb', line 5

def original_exception
  @original_exception
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/restman/exception.rb', line 4

def response
  @response
end

Instance Method Details

#default_messageObject



39
40
41
# File 'lib/restman/exception.rb', line 39

def default_message
  self.class.name
end

#http_bodyObject



27
28
29
# File 'lib/restman/exception.rb', line 27

def http_body
  @response.body if @response
end

#http_codeObject



14
15
16
17
18
19
20
21
# File 'lib/restman/exception.rb', line 14

def http_code
  # return integer for compatibility
  if @response
    @response.code.to_i
  else
    @initial_response_code
  end
end

#http_headersObject



23
24
25
# File 'lib/restman/exception.rb', line 23

def http_headers
  @response.headers if @response
end

#to_sObject



31
32
33
# File 'lib/restman/exception.rb', line 31

def to_s
  message
end