fix incorrect handling of error

done for [AGIOS-62](https://issues.jboss.org/browse/AGIOS-62)