basic error handling.
Merge pull request #2 from glebb/master

basic error handling.