add error return value for function that can fail
Merge pull request #3 from olt/error-handling

Improve error handling