Voltaire said this quote

What's optimism? said Cacambo. Alas, said Candide, it is a mania for saying things are well when one is in hell.