Fix error reporting
Merge pull request #240 from andreypopp/patch-1

Fix error reporting