3.1. pci.exceptions module

This library contains the exceptions raised by PCI C++ code, translated to Python equivalent exceptions.

class pci.exceptions.GetMessageImpl

Bases: object

Implements the method getMessage(). It exists to support code that that called getMessage()

getMessage()

Get the message for this object. This, method exists for backwards compatibility due to the elimination of the class pci.exceptions.UnicodeSafeException. If your code used this method to get an exception’s message, your code should continue to work correctly.

You should consider replacing all calls to getMessage() with str(e), which is the pythonic way to get an exception’s message.

This method simply does: return str(self)

exception pci.exceptions.LicenseException(desc)

Bases: GetMessageImpl, PermissionError

Raised when a licensing error occurs.

Note that this class does not derive from PCIException.

exception pci.exceptions.PCIException(desc)

Bases: Exception, GetMessageImpl

PCIException is the base class for exceptions raised by PCI code.

getReason()

Get the reason for this exception. This strips everything before the last “Reason:” in the exception’s message. It can make for a nicer looking error message to the user.

exception pci.exceptions.OSException(desc)

Bases: PCIException, OSError

Raise when a problem related to the operating system, that cannot be mapped to one of the OSException subclasses, is encountered.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching OSException exceptions does not catch OSError exceptions.

exception pci.exceptions.LibraryException(desc)

Bases: PCIException, ImportError

Raised when loading libraries fail.

Catching ImportError exceptions will handle this exception as well. The inverse is not true, catching LibraryException exceptions does not catch ImportError exceptions.

exception pci.exceptions.MemoryAllocationException(desc)

Bases: OSException, MemoryError

Raised when memory allocation fails.

Catching MemoryError exceptions will handle this exception as well. The inverse is not true, catching MemoryAllocationException exceptions does not catch MemoryError exceptions.

exception pci.exceptions.OutOfDiskSpaceException(desc)

Bases: OSException

Raised when there is not enough disk space.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching OutOfDiskSpaceException exceptions does not catch OSError exceptions.

exception pci.exceptions.ExternalException(desc)

Bases: PCIException, RuntimeError

Raised when an error from 3rd party libraries that can not be mapped to an existing exception is raised.

Catching RuntimeError exceptions will handle this exception as well. The inverse is not true, catching ExternalException exceptions does not catch RuntimeError exceptions.

exception pci.exceptions.DataException(desc)

Bases: PCIException, RuntimeError

The base class for all exceptions that are raised when data is being manipulated.

Catching RuntimeError exceptions will handle this exception as well. The inverse is not true, catching DataException exceptions does not catch RuntimeError exceptions.

exception pci.exceptions.DataTypeException(desc)

Bases: DataException, TypeError

Raised when data has an invalid type.

Catching TypeError exceptions will handle this exception as well. The inverse is not true, catching DataTypeException exceptions does not catch TypeError exceptions.

exception pci.exceptions.ParameterException(desc)

Bases: DataException, ValueError

Raised when a parameter is invalid.

Catching TypeError exceptions will handle this exception as well. The inverse is not true, catching DataTypeException exceptions does not catch TypeError exceptions.

exception pci.exceptions.FormatException(desc)

Bases: DataException, ValueError

Raised when data is formatted is incorrectly. For example, if a date is expected in dd/mm/yyyy format and received in yyyy/mm/dd format.

Catching ValueError exceptions will handle this exception as well. The inverse is not true, catching FormatException exceptions does not catch ValueError exceptions.

exception pci.exceptions.OutOfBoundsException(desc)

Bases: DataException, IndexError

Raised when a variable is out of bounds.

Catching IndexError exceptions will handle this exception as well. The inverse is not true, catching OutOfBoundsException exceptions does not catch IndexError exceptions.

exception pci.exceptions.IOException(desc)

Bases: PCIException, OSError

Raised when an error related to I/O occurs that cannot be mapped in any of its subclasses.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching IOException exceptions does not catch OSError exceptions.

exception pci.exceptions.DeviceException(desc)

Bases: IOException, OSError

Raised when a hardware device is not found or not functioning properly.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching DeviceException exceptions does not catch OSError exceptions.

exception pci.exceptions.FileException(desc)

Bases: IOException, OSError

Raised when there is a file related error that doesn’t match any other subclass of FileException.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching FileException exceptions does not catch OSError exceptions.

exception pci.exceptions.FileAccessException(desc)

Bases: FileException, PermissionError

Raised when a file cannot be accessed.

Catching PermissionError exceptions will handle this exception as well. The inverse is not true, catching FileAccessException exceptions does not catch PermissionError exceptions.

exception pci.exceptions.FileFormatException(desc)

Bases: FileException, OSError

Raised when a file has an invalid format.

Catching OSError exceptions will handle this exception as well. The inverse is not true, catching FileFormatException exceptions does not catch OSError exceptions.

exception pci.exceptions.FileAlreadyExistsException(desc)

Bases: FileException, FileExistsError

Raised when a file exists.

Catching FileExistsError exceptions will handle this exception as well. The inverse is not true, catching FileAlreadyExistsException exceptions does not catch FileExistsError exceptions.

exception pci.exceptions.FileNotFoundException(desc)

Bases: FileException, FileNotFoundError

Raised when a file is not found.

Catching FileNotFoundError exceptions will handle this exception as well. The inverse is not true, catching FileNotFoundException exceptions does not catch FileNotFoundError exceptions.

exception pci.exceptions.FileCorruptException(desc)

Bases: FileException, TypeError

Raised when the file has the expected type but is corrupt.

Catching TypeError exceptions will handle this exception as well. The inverse is not true, catching FileCorruptException exceptions does not catch TypeError exceptions.

exception pci.exceptions.ParserException(desc)

Bases: FileException, TypeError

Raised when data cannot be parsed.

Catching TypeError exceptions will handle this exception as well. The inverse is not true, catching ParserException exceptions does not catch TypeError exceptions.

exception pci.exceptions.NetworkException(desc)

Bases: IOException, ConnectionError

Raised when a network resource is not available.

Catching ConnectionError exceptions will handle this exception as well. The inverse is not true, catching NetworkException exceptions does not catch ConnectionError exceptions.

exception pci.exceptions.TimeOutException(desc)

Bases: NetworkException, TimeoutError

Raised when network time out occurs.

Catching TimeoutError exceptions will handle this exception as well. The inverse is not true, catching TimeOutException exceptions does not catch TimeoutError exceptions.

exception pci.exceptions.TransformationException(desc)

Bases: PCIException, ValueError

Raised when an error occurs during data processing.

Catching ValueError exceptions will handle this exception as well. The inverse is not true, catching TransformationException exceptions does not catch ValueError exceptions.

exception pci.exceptions.MathException(desc)

Bases: TransformationException, ArithmeticError

Raised when a mathematical error occurs.

Catching ArithmeticError exceptions will handle this exception as well. The inverse is not true, catching MathException exceptions does not catch ArithmeticError exceptions.

exception pci.exceptions.ArithmeticException(desc)

Bases: MathException

Raised when a error occurs with basic arithmetic operations.

Catching ArithmeticError exceptions will handle this exception as well. The inverse is not true, catching ArithmeticException exceptions does not catch ArithmeticError exceptions.

exception pci.exceptions.DemoModeException(desc)

Bases: PCIException, PermissionError

Raised when an error related to demo mode occured.

Catching PermissionError exceptions will handle this exception as well. The inverse is not true, catching DemoModeException exceptions does not catch PermissionError exceptions.

exception pci.exceptions.UnsupportedException(desc)

Bases: PCIException, NotImplementedError

Raised when something is unsupported.

Catching NotImplementedError exceptions will handle this exception as well. The inverse is not true, catching UnsupportedException exceptions does not catch NotImplementedError exceptions.