If you want to commit to losing weight, then you must be able to persist through failure. Everyone who has accomplished something of any significance has struggled with failure at one or more points in their journey. The difference is they didn't quit when it got tough, they persisted through it and learned a lesson.
When the going gets tough, the tough get going.
Those are the two keys in dealing with failure. You must persist and learn.
If you slip on your diet, or miss a day of exercise, please don't fret about it and don't let it derail you. Push it from your mind. Focus on all your positive days, not the one slip up. Remember it's all about getting to a healthy weight and living a healthy lifestyle, the more good days add up and before you know it bad days become few and far between. But the trick is to keep going and push through the bad days. Treat it as a cheat day and move on. This is how you persist, failing for a day is OK, just don't let that day stretch into a week and then a month.
You have to accept failures as natural and develop a tough mental state to deal with them.
The second step is to learn from your mistakes. Quite often learning from your mistakes will be more efficient than learning from your successes. When you fail, treat it as a lesson learned. It's just like in business, when you fail at something, you learn the things that don't work.
This is the same with weight loss. If you have slipped off your new diet every time you drink, then maybe you avoid drinking. If you realize that every Friday you miss out on exercise because of a late work meeting, then reschedule your workout. It really is that simple. Please don't be like so many people who complicate the process. It will only make you feel like you are defeated before you ever get started.
I think my favorite saying sums it up, inch by inch, everything's a cinch! I also like this one by Thomas A Edison. I have not failed. I have just found 10,000 ways that won't work.
You see, failure is a natural part of life, along with death and taxes. You can't avoid it, and even if you could, you wouldn't want to. The lessons of life are learned through your failures along with your successes. Don't fear failure, persist through and learn from them.