4.6. Exceptions
The following exceptions are pywbem specific exceptions that can be raised at the WBEM client library API.
- class pywbem.ConnectionError(message, conn_id=None)[source]
This exception indicates a problem with the connection to the WBEM server. A retry may or may not succeed.
Derived from
Error
.- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. Omitted or None if the error did not happen in context of any connection, or if the connection context was not known.
- Variables:
args – A tuple (message, ) set from the corresponding init arguments.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
- class pywbem.AuthError(message, conn_id=None)[source]
This exception indicates an authentication error with the WBEM server, either during TLS/SSL handshake, or during HTTP-level authentication.
Derived from
Error
.- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. Omitted or None if the error did not happen in context of any connection, or if the connection context was not known.
- Variables:
args – A tuple (message, ) set from the corresponding init arguments.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
- class pywbem.HTTPError(status, reason, cimerror=None, cimdetails=None, conn_id=None, request_data=None, response_data=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.
Occurrence of this exception nearly always indicates an issue with the WBEM server.
- 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 HTTP 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.
conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
response_data (string) – CIM-XML response string. None means the exception does not store a CIM-XML response.
- Variables:
args – A tuple (status, reason, cimerror, cimdetails) set from the corresponding init arguments.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
CIMOM-specific details on the situation reported in the CIMError header field.
Value of CIMError HTTP header field in response, if present.
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
HTTP reason phrase.
request_data
CIM-XML request string (settable).
response_data
CIM-XML response string (settable).
HTTP status code.
- property cimdetails
CIMOM-specific details on the situation reported in the CIMError header field.
The value is a dictionary with:
Key: header field name (e.g. PGErrorDetail).
Value: header field value.
- Type:
- property cimerror
Value of CIMError HTTP header field in response, if present.
None, otherwise.
See DSP0200 for a list of values.
- Type:
- class pywbem.TimeoutError(message, conn_id=None)[source]
This exception indicates that a CIM operation to a server or a CIM indication delivery to a listener could not be completed.
Derived from
Error
.- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. Omitted or None if the error did not happen in context of any connection, or if the connection context was not known.
- Variables:
args – A tuple (message, ) set from the corresponding init arguments.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
- class pywbem.ParseError(message, conn_id=None, request_data=None, response_data=None)[source]
This exception is a base class for exceptions that indicate a parsing error with the CIM-XML operation response the pywbem client received, or with the CIM-XML indication request the pywbem listener received.
Derived from
Error
.The CIM-XML response data is part of the str() representation of the exception.
This exception is a base class for more specific exceptions:
CIMXMLParseError
- Issue at the CIM-XML level (e.g. NAME attribute missing on CLASS element)XMLParseError
- Issue at the XML level (e.g. ill-formed XML)HeaderParseError
- Issue with HTTP headers (e.g. invalid content-type header)
Occurrence of this exception nearly always indicates an issue with the WBEM server.
- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
response_data (string) – CIM-XML response string. None means the exception does not store a CIM-XML response.
- Variables:
args – A tuple (message, ) set from the corresponding init argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
request_data
CIM-XML request string (settable).
response_data
CIM-XML response string (settable).
- class pywbem.CIMXMLParseError(message, conn_id=None, request_data=None, response_data=None)[source]
This exception indicates a specific kind of
ParseError
that is an issue at the CIM-XML level.Example: ‘NAME’ attribute missing on ‘CLASS’ element.
Occurrence of this exception nearly always indicates an issue with the WBEM server.
- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
response_data (string) – CIM-XML response string. None means the exception does not store a CIM-XML response.
- Variables:
args – A tuple (message, ) set from the corresponding init argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
request_data
CIM-XML request string (settable).
response_data
CIM-XML response string (settable).
- class pywbem.XMLParseError(message, conn_id=None, request_data=None, response_data=None)[source]
This exception indicates a specific kind of
ParseError
that is an issue at the XML level.Example: Ill-formed XML.
Occurrence of this exception nearly always indicates an issue with the WBEM server.
- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
response_data (string) – CIM-XML response string. None means the exception does not store a CIM-XML response.
- Variables:
args – A tuple (message, ) set from the corresponding init argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
request_data
CIM-XML request string (settable).
response_data
CIM-XML response string (settable).
- class pywbem.HeaderParseError(message, conn_id=None, request_data=None, response_data=None)[source]
This exception indicates a specific kind of
ParseError
that is an issue with an HTTP header.Example: Invalid content-type.
Occurrence of this exception nearly always indicates an issue with the WBEM server.
- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
response_data (string) – CIM-XML response string. None means the exception does not store a CIM-XML response.
- Variables:
args – A tuple (message, ) set from the corresponding init argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
request_data
CIM-XML request string (settable).
response_data
CIM-XML response string (settable).
- class pywbem.CIMError(status_code, status_description=None, instances=None, conn_id=None, request_data=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.conn_id (connection id) – Connection ID of the connection in whose context the error happened. None if the error did not happen in context of any connection, or if the connection context was not known.
request_data (string) – CIM-XML request string. None means the exception does not store a CIM-XML request.
- Variables:
args – A tuple (status_code, status_description, instances) set from the corresponding init arguments.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
CIM instances returned by the WBEM server in the error response, that provide more details on the error.
request_data
CIM-XML request string (settable).
Numeric CIM status code.
Symbolic name of the CIM status code.
CIM status description text returned by the server, representing a human readable message describing the error.
- property instances
CIM instances returned by the WBEM server in the error response, that provide more details on the error.
New in pywbem 0.13.
None if there are no such instances.
- Type:
List of
CIMInstance
- property status_code
Numeric CIM status code.
New in pywbem 0.9.
Example: 5
See CIM status codes for constants defining the numeric CIM status code values.
- Type:
- property status_code_name
Symbolic name of the CIM status code.
Example: “CIM_ERR_INVALID_CLASS”
New in pywbem 0.9.
If the CIM status code is invalid, the string “Invalid status code <status_code>” is returned.
- Type:
- property status_description
CIM status description text returned by the server, representing a human readable message describing the error.
New in pywbem 0.9.
Example: “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.
- Type:
- class pywbem.ModelError(message, conn_id=None)[source]
This exception indicates an error with the model implemented by the WBEM server, that was detected by the pywbem client.
Derived from
Error
.Examples are mismatches in data types of CIM elements (properties, methods, parameters) between classes and instances, CIM elements that appear in instances without being declared in classes, or violations of requirements defined in advertised management profiles.
- Parameters:
message (string) – Error message (will be put into args[0]).
conn_id (connection id) – Connection ID of the connection in whose context the error happened. Omitted or None if the error did not happen in context of any connection, or if the connection context was not known.
- Variables:
args – A tuple (message, ) set from the corresponding init argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
conn_id
Connection ID of the connection in whose context the error happened.
conn_str
String that identifies the connection in exception messages.
- class pywbem.Error(*args, **kwargs)[source]
Abstract base class for pywbem client specific exceptions.
- Parameters:
*args – Any other positional arguments are passed to
Exception
.conn_id (connection id) – Connection ID of the connection in whose context the error happened. Omitted or None if the error did not happen in context of any connection, or if the connection context was not known. Must be specified as a keyword argument.
Methods:
add_note
Exception.add_note(note) -- add a note to the exception
with_traceback
Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
Attributes:
Connection ID of the connection in whose context the error happened.
String that identifies the connection in exception messages.
- property conn_id
Connection ID of the connection in whose context the error happened.
None if the error did not happen in context of any connection, or if the connection context was not known.
- Type:
- property conn_str
String that identifies the connection in exception messages.
- Type: