“You have to be tough to make it in New York City,” Mayor Bill de Blasio boasted, choosing to jeer at Amazon as it canceled its plans on Thursday to build a new headquarters in Queens, after some local officials angrily criticized its proposal.

What a strange thing for the mayor to take pride in. It’s certainly true that you have to be tough these days. But that’s because the subways don’t work, the streets are gridlocked, the housing is unaffordable, the shelters are overcrowded, and the schools are segregated and often inadequate. Now think how much tougher it’ll become for the typical citizen — not the ones who ride in chauffeured government cars — if New York gets a reputation for the smugness of its politicians and their hostility to business.

There were all sorts of problems with the deal New York cut to bring Amazon to the city, and Amazon is no paragon, but its abrupt withdrawal was a blow to New York, which stood to gain 25,000 jobs and an estimated $27 billion in tax revenue over the next two decades. This embarrassment to the city presents a painful lesson in how bumper-sticker slogans and the hubris of elected — and corporate — officials can create losers on all sides.

Gov. Andrew Cuomo and Mr. de Blasio, in a rare fit of comity, rolled out the red carpet for Amazon, for what would have been one of the biggest economic deals ever in the state. They offered the company $3 billion in tax benefits to build a campus in the Long Island City neighborhood. But it was clear as soon as the company, governor and mayor announced the deal in November that not all New Yorkers felt welcoming.