better error handling when saving an entity (+test)