Add support for Exceptions

Raise exceptions if an error occurs