Module: Zimbra::HandsoapErrors

Included in:
AuthService, HandsoapService
Defined in:
lib/zimbra/handsoap_service.rb

Defined Under Namespace

Classes: SOAPFault

Constant Summary collapse

@@response =
nil

Instance Method Summary collapse

Instance Method Details

#http_error?Boolean

Returns:



25
26
27
# File 'lib/zimbra/handsoap_service.rb', line 25

def http_error?
  @@response && (500..599).include?(@@response.status)
end

#http_not_found?Boolean

Returns:



28
29
30
# File 'lib/zimbra/handsoap_service.rb', line 28

def http_not_found?
  @@response && (400..499).include?(@@response.status)
end

#on_after_create_http_request(request) ⇒ Object



18
19
20
# File 'lib/zimbra/handsoap_service.rb', line 18

def on_after_create_http_request(request)
  @@response = nil
end

#on_http_error(response) ⇒ Object



9
10
11
12
13
# File 'lib/zimbra/handsoap_service.rb', line 9

def on_http_error(response)
  @@response = response
  return nil if soap_fault_not_found?
  report_error(response) if http_error?
end

#report_error(response) ⇒ Object

Raises:



14
15
16
17
# File 'lib/zimbra/handsoap_service.rb', line 14

def report_error(response)
  message = response.body.scan(/<soap:faultstring>(.*)<\/soap:faultstring>/).first
  raise SOAPFault, message
end

#soap_fault_not_found?Boolean

Returns:



22
23
24
# File 'lib/zimbra/handsoap_service.rb', line 22

def soap_fault_not_found?
  @@response && @@response.body =~ /no such/
end