Implemented basic error handling with a new Exception class.