I definitely understand. I've been there.

Just try to remind yourself that the important thing is not the grade, it's whether you learned. If you got a bad grade, but from that you learned that a certain study method doesn't work for you, then that's not a failure. You'll know what not to do next time. It's only a failure if you don't learn from it.
Here's a video that talks about some of the most famous people in the world and the failures they learned from: