吃一堑长一智。

A fall into a pit, a gain in your wit.

Source: Tatoeba

Sentence Composition