The mayor, John Tory, who had led the city since 2014, apologized for what he called a serious error in…