It can be interesting and mentally profitable to analyze failure. We already know this; you, of course, already know this.
But many times, upstanding and smart and thorough people avoid analyzing what environmental factors contributed to failure.
This is wise -- it's too easy to veer into excuses. And if you never credit the environment for contributing to failure, you of course never excuse yourself and your responsibility to get results.
Yet -- !
If you do start doing this analysis, you'll realize things. You'll realize you'll often make more mistakes when tired, when in a bad mood, when fatigued, when things are moving faster than you can grasp, and so on, and so forth.
If you break a diet, fail to make business calls timely, fail to seize an opportunity, whatever -- analyze what environmental stressors and factors might have contributed to that.
It doesn't excuse a lack of judgment, willpower, or anything else. But the wise path is often to set about removing those hostile environmental factors, as to make thriving easier.