Whenever you have a setback, besides looking at the outcome, spend more time on the process that lead to that failure. A student who graduated with a poor grade in a university should examine his/her actions in school. It is only by looking at that process that the student will avoid repeating poor grades in future life endeavors.
Sometimes, poor grades could be due to misalignments: you applied for course A, you ended up with Course B because you just wanted to matriculate for college education. But we also have extremely lazy students who made bad choices: sleeping when others were studying. Not fixing those attitudes would result to future life failures.
If you worked hard, gave your best and ended up with poor grades: the world has a future for you. That attitude will lead to opportunities. Do not beat yourself down because of failure. Rather, make sure the cause of that failure is not systemic.
Companies hire top graduating students not necessarily because they are the smartest BUT because being the top of the class symbolizes dedication, commitment, and focus. The implication is that if the student (now worker) commits to those principles at work, the company will win. Simply, grades are barometers to ascertain your tenacity level: are you a person that can get something done or someone who does not care? The differences between A and B are marginal; simple things but with huge impacts.
I was a bookworm in university: yes, the too-much reading type because I knew I was not the smartest in class. But I knew if I worked hardest and smartest, I would come on top. That is a principle I apply in life: put extra efforts to mitigate deficiencies in capabilities and quickly learn and advance.
The biggest failure is NOT fixing things that lead to failures.