This is an example of thoughts causing feelings. According to the Cognitive theory, emotions are products of our thoughts, not situations. Sometimes we have thoughts called irrational thoughts, which are products of situations we live in the past, these thoughts are not in accordance with reality.
I hope this answer can help you.