If it weren't for that stress, I wouldn't be a programmer. It is that variability, and challenge that keeps me coming back and satiates my desire to problem solve. But I understand, in the moment, it is hard to step back and see programming this way.
The only thing I do when feeling stressed, is to physically step back. I walk away from the computer, go on on a run, or get some sleep.
It is often within this absence that the solution to my programming problem emerges.