Fix exception handling

Was catching the wrong exception