A failure does not have to lead to negative thinking. Positive outlook and self esteem are not necessarily damaged because you fail something. But, if you fail an exam then it's pointless to pretend otherwise; how do you fix something if people are telling you it's not broken.