How a mayor’s quest to unmask a foul-mouthed Twitter user blew up in his face