Skip to content

jmp1985/halerror

Repository files navigation

halerror

The best python exception library

PyPI PyPI - Python Version Code style: black Documentation Status Building Publishing Codecov Language grade: Python Total alerts

This python library implements a sci-fi exception class!

Installation

The package is available from PyPI. To install using pip, do the following:

pip install halerror

To install from source, clone this repository and then do the following:

python setup.py install

Testing

To run the tests, clone this repository and the do the following:

python setup.py test

Building the documentation

To build the documenation, clone this repository and the do the following:

pip install -e .[build_sphinx]
python setup.py build_sphinx

Usage examples

The exception class can be used as follows:

from halerror import HalError

def open_pod_bay_doors():
    raise HalError("Open the pod bay doors, HAL.")

open_pod_bay_doors()

This will result in the following error output, where ${NAME} is the username of the person running the software:

halerror.HalError: Open the pod bay doors, HAL

I'm sorry, ${NAME}. I'm afraid I can't do that.

Having all your exceptions formatted like this is as easy as adding the following lines to your code

from halerror import HalError

try:
    open_pod_bay_doors()
except Exception as error:
    raise HalError(error) from error

Documentation

You can find the full documentation on Read the Docs.

Issues

Please use the GitHub issue tracker to submit bugs or request features.

License

Copyright James Parkhurst, 2019.

Distributed under the terms of the BSD license, halerror is free and open source software.