#357 handle error scenarios
Merge pull request #422 from krzyk/357

#422: pull request #357 handle error scenarios