Improved error handling.

Added a class to handle outputing errors.