Fix wrong management of error cases.