We need to learn to defer the emotions before they ever come. We can do that by controlling our expectations. By controlling our expectations we can stop setting ourselves up.
When we have high expectations our hopes go up. When our hopes are high we are at risk of emotional disappointment. The Bible says, Hope deferred makes the heart sick (Proverbs 13:12 NASU).
If we think about it, we will realize our greatest disappointments follow our highest expectations. If you want to prevent the disappointment that comes with failure you will need to keep your hopes in check.