Those are all great tips listed above, and it's so awesome that you are reaching out for suggestions, rather than giving up! The mental side of yoga is every bit as important to grow in as the physical, so maybe for you, this is your yoga growth journey, for now.
Negative thoughts are normal to have, any time, any place. Thoughts are the soundtrack of our brain. When they are positive, they can be helpful, but negative ones, not so much... In yoga we notice our thoughts so much more because we are tuned inward and have turned off all of the usual distractions of life. So, partly you might just be noticing your thoughts more. It's totally OK to have negative thoughts in yoga or anytime, but it's what you choose to do with those thoughts that counts. Simply notice them, and let them go. No judgement. You can choose to refocus on something else, like your breath as Larry mentioned, or to an intention you may have set for yourself at the beginning of class. If you haven't gotten used to setting an intention, that might help a lot. For example, you might start each class with the mantra, "I am present," and return to this statement whenever you find your mind wandering. Choose to be present to what is happening with your body, your breath, in the here and now of the class and let go of any judgement of what may have happened before or what might happen later. "I am here, and I am good enough" is another great intention/mantra to try. I love the quote by Lau Tzo: "Let things flow naturally forward in whatever direction they like."
Sitting with the discomfort, whether it's physical or mental, is where we grow in yoga and in life