improve exception handling (bnc#840255)