There is no way around it: The greatest learning opportunity is when things don’t go according to plan. When you envisioned X and Y or Z happens, and you have very little idea about why that is.
When that happens – and it will happen – it is an open invitation to learn. It is an invitation to go back, investigate and walk through everything you have done in order to try and find the spot(s), where you missed something important.
It is by no means certain that you will be able to find it at the first time of asking. But if you adapt an experimental approach and try to adjust here and there in a controlled way, chances are that you will finally understand what happened, and what you could have done and should be doing forward to make it right. And voilá; you will actually have learned something.