Menu

#36 Issues with exceptions that can be raised

closed
None
5
2015-01-22
2015-01-19
No

It is difficult for client applications (code using WBEMConnection) to differentiate between errors they have made, errors made by the PyWBEM client code, and errors returned by the WBEM server. In addition, some exceptions of underlying modules are not handled properly.
In addition, the text message of some exceptions misses important information.

A good approach would be for a user of the WBEMConnection class, to raise all errors that are not programming errors, as CIMError exceptions, making sure that CIMError exceptions for an error code of 0 always contain the internally raised exception object as the third tuple member. This additional tuple item is a compatible change for existing client code, because Python allows assignment of a tuple into one with less members.

Suggested changes visible to user of WBEMConnection:

  • In cim_operations.imethodcall() and methodcall(), turn the ParseError and ExpatError exceptions raised by minidom.parseString() for invalid CIM-XML in the response message, into CIMError(0,..) exceptions.

  • In cim_operations.imethodcall() and methodcall(), add checking for unexpected XML elements in the response message, and raise them as CIMError(0,..) exceptions.

  • In tupleparse.py, change the ValueError exception raised when property values cannot be created from the CIM-XML response, into a CIMError(0) exception.

  • In tupleparse.py, change the ExpatError exception that is raised when the CIM-XML response contains numeric character references of invalid XML characters (e.g. ''), into a CIMError(0) exception.

Improvements in errors raised internally (that get turned into CIMError for users of WBEMConnection):

  • In cim_http.py, add handling of the httplib.IncompleteRead exception, and raise that error as cim_http.Error.

  • In cim_http.py, there is useless catching and re-raising of cim_http.AuthError for instrinsic method calls, this could be made consistent with extrinsic method calls.

  • In cim_http.py, add new exception classes cim_http.ConnectionError and cim_http.TimeoutError for better distinguishing these situations.

  • In cim_http.py, improve the error message for invalid URL by adding the offending URL to the message text.

  • In cim_http.py, add handling of httplib.NotConnected raised by send().

  • In cim_types.py, improve the text of the ValueError exception for invalid datetime field values (e.g. when returned by CIM operations).

Discussion

  • Andreas Maier

    Andreas Maier - 2015-01-21

    Fixed all of those in commit level r721.
    The exceptions that can be seen by a user of class WBEMConnection are documented in its class description.

     
  • Andreas Maier

    Andreas Maier - 2015-01-21
    • status: open --> closed
     
MongoDB Logo MongoDB