Adds generic error handling

A horrible implementation to handle errors until this can be refactored.

Closes #180