Merge pull request #271 from mehlis/master

fix wrong error handling introduced in 945aef