Exception: RHapi::ConnectionError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/r_hapi/r_hapi_exception.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_string) ⇒ ConnectionError

Returns a new instance of ConnectionError.



5
6
7
# File 'lib/r_hapi/r_hapi_exception.rb', line 5

def initialize(error_string)
  @error_string = error_string
end

Instance Attribute Details

#error_stringObject (readonly)

Returns the value of attribute error_string.



3
4
5
# File 'lib/r_hapi/r_hapi_exception.rb', line 3

def error_string
  @error_string
end

Class Method Details

.raise_error(response) ⇒ Object

Raises:

  • (exception)


21
22
23
24
# File 'lib/r_hapi/r_hapi_exception.rb', line 21

def self.raise_error(response)
  exception = RHapi::ConnectionError.new(response)
  raise(exception, exception.message)
end

Instance Method Details

#messageObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/r_hapi/r_hapi_exception.rb', line 9

def message
  if @error_string =~ /401/
    "HubSopt returned a 401 error:  #{error_string}" 
  elsif @error_string =~ /404/
    "HubSopt returned a 404 error:  #{error_string}"
  elsif @error_string =~ /500/
    "HubSopt returned a 500 error:  #{error_string}"
  else
    @error_string
  end
end