Reverse the list, return an error code if something goes wrong