4.6. Exceptions¶
The following exceptions are pywbem specific exceptions that can be raised at the WBEM client library API.
-
class
pywbem.
ConnectionError
[source]¶ This exception indicates a problem with the connection to the WBEM server. A retry may or may not succeed. Derived from
Error
.
-
class
pywbem.
AuthError
[source]¶ This exception indicates an authentication error with the WBEM server, either during TLS/SSL handshake, or during HTTP-level authentication. Derived from
Error
.
-
class
pywbem.
HTTPError
(status, reason, cimerror=None, cimdetails=None)[source]¶ This exception indicates that the WBEM server returned an HTTP response with a bad HTTP status code. Derived from
Error
.The args instance variable is a tuple (status, reason, cimerror, cimdetails).
The message instance variable is not set.
Parameters: - status (integer) – HTTP status code (e.g. 500).
- reason (string) – HTTP reason phrase (e.g. “Internal Server Error”).
- cimerror (string) – Value of the CIMError header field, if present. None, otherwise.
- cimdetails (dict) –
Dictionary with CIMOM-specific header fields with details about the situation reported in the CIMError header field.
- Key: header field name (e.g. PGErrorDetail)
- Value: header field value (i.e. text message)
Passing None will result in an empty dictionary.
-
status
¶ integer – HTTP status code (e.g. 500).
See RFC2616 for a list of HTTP status codes and reason phrases.
-
reason
¶ string – HTTP reason phrase (e.g. “Internal Server Error”).
See RFC2616 for a list of HTTP status codes and reason phrases.
-
cimerror
¶ string – Value of CIMError header field in response, if present. None, otherwise.
See DSP0200 for a list of values.
-
cimdetails
¶ dict – CIMOM-specific details on the situation reported in the CIMError header field, with:
- Key: header field name (e.g. PGErrorDetail).
- Value: header field value.
-
class
pywbem.
TimeoutError
[source]¶ This exception indicates that the client timed out waiting for the WBEM server. Derived from
Error
.
-
class
pywbem.
ParseError
[source]¶ This exception indicates a parsing error with the CIM-XML response returned by the WBEM server, or in the CIM-XML request sent by the WBEM listener. Derived from
Error
.
-
class
pywbem.
CIMError
(status_code, status_description=None, instances=None)[source]¶ This exception indicates that the WBEM server returned an error response with a CIM status code. Derived from
Error
.Accessing the CIM status code of a
CIMError
object:In Python 2, any
Exception
object can be accessed by index and slice and will delegate such access to itsargs
instance variable. In Python 3, that ability has been removed.In pywbem 0.9, the
status_code
andstatus_description
properties were added.Therefore, the following approach is not recommended, because it does not work on Python 3:
except CIMError as exc: status_code = exc[0]
The following approach works for pywbem 0.7 or newer:
except CIMError as exc: status_code = exc.args[0]
The following approach is recommended when using pywbem 0.9 or newer:
except CIMError as exc: status_code = exc.status_code
Parameters: - status_code (integer) – Numeric CIM status code.
- status_description (string) – CIM status description text returned by the server, representing a human readable message describing the error. None, if the server did not return a description text.
- instances (list of
CIMInstance
) – List of CIM instances returned by the WBEM server in the error response, that provide more details on the error. None if there are no such instances.
Variables: args – A tuple (status_code, status_description) set from the corresponding init arguments.
-
status_code
¶ New in pywbem 0.9.
integer: Numeric CIM status code (e.g. 5).
See CIM status codes for constants defining the numeric CIM status code values.
-
status_code_name
¶ New in pywbem 0.9.
string: Symbolic name of the CIM status code (e.g. “CIM_ERR_INVALID_CLASS”).
If the CIM status code is invalid, the string “Invalid status code <status_code>” is returned.
-
status_description
¶ New in pywbem 0.9.
string: CIM status description text returned by the server, representing a human readable message describing the error (e.g. “The specified class does not exist.”).
If the server did not return a description, a short default text for the CIM status code is returned. If the CIM status code is invalid, the string “Invalid status code <status_code>” is returned.
-
instances
¶ New in pywbem 0.13.
List of
CIMInstance
: List of CIM instances returned by the WBEM server in the error response, that provide more details on the error. None if there are no such instances.