"So that you may not despair," meaning: grieve, "over what has escaped you," meaning: of the world, "and not exult in what He has given you," meaning: of the world.
Muhammad said: It has been said that the meaning of "exult" here is: to exult with an intense joy in which you behave with insolence and arrogance. The evidence for this is: "And Allah does not like everyone who is a self-deluded boaster." He indicated by this that He condemned the exultation in which its possessor behaves with arrogance and insolence. As for joy in the grace of Allah and gratitude for it, that is not condemned. Likewise, "so that you may not despair over what has escaped you," means: do not grieve with an intense grief in which you transgress, regardless of what is taken from you or what has escaped you.