Disclaimer: trying this for myself, but it may or may not be applicable or good for anyone else because why, how, and what people behave varies. And this is for a small mistakes. Anyway...
short-term:
It doesn't sound like there was any major legal, monetary, occupational, etc. injury to yourself or others due to your mistake, so allow yourself to make a mistake. There are others who make mistakes and don't give it a second thought. Before you hit yourself, imagine their thought process where they never even consider self-punishment but go right on to whatever next step is that they do. Think to yourself that you're allowed to make mistakes without derision, criticism or punishment. Because expecting complete perfection for humans doesn't make sense and is unreasonable. The best software has at least one bug in it. Allow yourself to mistakes and move right to whatever you'd be doing if you never thought of the mistake or yourself as bad, but just that mistakes happening is normal for all humans.
long-term:
Try to figure out a possible reason why you punish yourself so much and work on changing that. for me, i realized that i was never allowed mistakes. For example:
My grades: A, A, A, A, A, B.
Parents: "Why the B? B is not good. How do you expect to go to university with a B?"
While other kids got money for bringing a B, I got criticized for it. That fucks with your brain. Anyway, I stay up late to finish all my homework.
I get yelled at for not sleeping on time, and warned that tomorrow I'll be tired.
But sleep won't get that B up to an A, so I endeavor to keep working while getting yelled at.
Next morning, I feel nauseated from hardly sleeping. I don't want to eat because I know I will vomit.
I get yelled at for not eating because "breakfast is very important."
I succumb and eat, like they said I should. I vomit.
I get yelled at for vomiting and told, "see, I told you that you should sleep on time. this is what happens."
No matter what I did, it was always wrong. And they were always right. But were they? I'm now burned out and almost everything in life is difficult because I have to get it all correct and proper the first time. So maybe they and whoever else later would shit on me weren't so right. Especially when I know there are others who have "mistakes", don't feel any punishment for it, and are happier than I am. And specifically, I would have done fine in life with the B, with not eating if I feel nauseated. I would've been better off semi-happily living with mistakes than forcing myself to never make one and anguishing whenever one was made.
To this day I think I'm a fuck up. It doesn't matter what my accomplishments are. Even when someone praises me, I can convince them it was a fluke and that I actually am a stupid person. Not because I actually am a failure or useless, but because I was treated as a failure and useless. It was learned behavior--but not necessarily accurate. So I try to learn a different behavior.
For me, I recall CPTSD mention re-parenting yourself. So I try to talk to myself or an imaginary child. I wouldn't shit on said child for a mistake. I wouldn't make a negative light of a mistake, but possibly enjoy something even with said mistake or continue on to the next step, either fixing the mistake if needed or accepting or adjusting to the mistake if it didn't need or couldn't be fixed. (BTW, for counter-balance, this re-parenting needs repeating as frequently as the many moments of derision and yelling.)
Anyway, I try to think: minor harm, minor foul.