Added error handling.
Merge pull request #9 from nullobject/refactor/error-handling

Added error handling.