Catch other exceptions when encoding