Exception: OpenfireAdmin::ResponceException

Inherits:
Exception
  • Object
show all
Defined in:
lib/openfire_admin/response_exception.rb

Overview

unexpected response found exception

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, res) ⇒ ResponceException

Returns a new instance of ResponceException.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/openfire_admin/response_exception.rb', line 8

def initialize(message,res)
  case res
  when Net::HTTPSuccess
    doc = HtmlParser.new(res.body)
    msgs = ( doc.search('//*[contains(@class,"jive-error-text") or contains(@class , "error")]') || [] ).map{|c| c.text.strip}
    if msgs.empty?
      super(message)
    else
      super("#{message} [#{msgs.join(' / ')}]")
    end
  when Net::HTTPRedirection
    super("#{message} redirct to=>#{res['location']}")
  when Net::HTTPNotFound
    super("#{message} Not found #{res.request.path}")
  else
    super("#{message} res.code=#{res.code}")
  end

  @response = res
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/openfire_admin/response_exception.rb', line 7

def response
  @response
end