This is the base class for all the services of the SDK. It contains the utility methods used by all of them.
Reads the response body assuming that it contains an action, checks if it contains a fault message, and if it does converts it to an Error and raises it. If it doesn't contain a fault then it just returns the action object.
This method is intended for internal use by other components of the SDK. Refrain from using it directly, as backwards compatibility isn't guaranteed.
@api private
# File lib/ovirtsdk4/service.rb, line 84 def check_action(response) begin reader = XmlReader.new(response.body) action = ActionReader.read_one(reader) ensure reader.close end unless action.fault.nil? raise_error(response, action.fault) end return action end
Reads the response body assuming that it contains a fault message, converts it to an Error and raises it.
This method is intended for internal use by other components of the SDK. Refrain from using it directly, as backwards compatibility isn't guaranteed.
@api private
# File lib/ovirtsdk4/service.rb, line 65 def check_fault(response) begin reader = XmlReader.new(response.body) fault = FaultReader.read_one(reader) ensure reader.close end raise_error(response, fault) end
Creates and raises an error containing the details of the given HTTP response and fault.
This method is intended for internal use by other components of the SDK. Refrain from using it directly, as backwards compatibility isn't guaranteed.
@api private
# File lib/ovirtsdk4/service.rb, line 32 def raise_error(response, fault) message = '' unless fault.nil? unless fault.reason.nil? message << ' ' unless message.empty? message << "Fault reason is \"#{fault.reason}\"." end unless fault.detail.nil? message << ' ' unless message.empty? message << "Fault detail is \"#{fault.detail}\"." end end unless response.nil? unless response.code.nil? message << ' ' unless message.empty? message << "HTTP response code is #{response.code}." end unless response.message.nil? message << ' ' unless message.empty? message << "HTTP response message is \"#{response.message}\"." end end raise Error.new(message) end