Fix wrong exception caught