Added error handling.
Merge pull request #18 from Hasimir/adderror

Added error handling.