all errors and exceptions

All exceptions/errors thrown from the maci library, including 3rd-party libraries, are redirected and handled with a maci-specific naming convention and helpful output.

The helpful output aims to try and provide useful and easy-to-understand information to quickly gather the reason for the exception thrown. This helpful output effort will consistently be improved or reiterated, and therefore an example will not be given.

path name convention

The exception path name convention contains 3-parts and ensures simplicity in locating the exception. Here is the convention and how to break it down:

Example exception name: maci.error.ExceptionName

  • maci is the top-level module name.

  • error is a submodule of maci, which contains definitions of various error or exception classes related to the maci module.

  • ExceptionName is the class name of the specific exception being raised.

handling exception thrown

Any time an exception is thrown, maci will provide the true module path followed by the class name of the exception to keep it simple, so there is no need to import anything additional to handle it. Example of maci exception thrown by load showing the full module and class path for bad filepath

maci.error.Load: [Errno 2] No such file or directory: ''

If needing to handle this, you would simply write or copy the exception path, and that will handle that specific exception.

Example handling above exception

except maci.error.Load:

maci base exception

All maci exceptions derive from its base exception MaciError. To handle all exceptions thrown from the maci library, you can handle the following exception path:


Last updated