Everyone makes mistakes. That's true at work as well.
No matter how good you are at your job, there will almost certainly be a time when you do something wrong. It probably won't be purposeful, but it will be a mistake nonetheless, and how you handle it determines what happens next.
While it's tempting to try sweep a mistake under the rug, the odds that will work are small. In addition, simply hoping to not get found out may lead to bigger problems down the road. If that happens, you're no longer just responsible for one mistake, but for any that build off the first.
Go to you boss and explain what happened. Don't make excuses and be ready to do whatever you can to fix the error.
Here's how that might go
Many years ago, I was a newspaper editor, back when photographs were still shot on film. Our lead story for the next day was about a car crash in a body of water where one man lost his life. We led with a large, dramatic photo of divers working in the water. It was a sensitive story, so my boss, the publisher, and I both signed off on the front page.
What we missed was that the arm of the man who had been killed was in the shot. It was a mistake that was both unintentionally insensitive and a violation of policy.
My boss called his boss to both report the error and make it clear that I had acted with his consent. We both called the family and offered a sincere apology.
It was unpleasant and embarrassing, but owning the error was the right thing to do. Had we not let corporate know and my boss had not accepted blame as the person in charge, I may have been fired. Had we not apologized to the family, they may have believed us callous rather than momentarily incompetent and they may have called out bosses, causing us both to lose our jobs.
What happens next?
Mistakes can have consequences. If you cost your company money or damage its reputation, you could lose your job or face punishment that falls short of termination.
That's not fun, and the type of person or people you work for will play a role here. Some bosses stand by employees when they make honest mistakes. Others will gladly cut the cord with one person if it benefits the larger company even slightly.
Hold your head high
There's honor in owning your mistakes even if you pay a price for it. Had I lost my job over the newspaper incident, it would have hurt, but I would have known my mistake was unintentional and that I did everything I could to rectify the pain I caused the deceased man's family.
Getting fired may hurt your chances the next time you're up for a job, but good employers will consider the circumstances. Tell the truth in your interview. Cover your error, how you handled it, and why you were terminated. Some, maybe many, hiring managers will appreciate the honesty and factor in the whole story before making a decision on you.
Most mistakes, of course, won't result in getting fired or even carry serious consequences. You should, however, still take them seriously and make every effort to handle them the right way.