Every time you fail there is a lesson to learn - new insights into behavior, figuring out ways to avoid temptation, learning how to redirect emotional eating, etc. Failure means there is still work to do and you can use this as an opportunity to grow and learn from the mistake. For example, the 2nd time I got sick after eating drive through french fries (after long bike rides), I figured out that I was craving salt and needed to rethink my hydration strategy. I found an electrolyte replacement that works well and I never crave salt anymore. Another example - sometimes I am sorely tempted by treats at work - especially when there is just a little bit of something left. I have "finished it off" more than a few times. Now, rather than eat "my share" I now throw it in the garbage bin (when no one is looking, of course). It is a strategy that I have pre-planned to change my thought pattern. Another example - Sometmes I am really hungry when I leave work, and can chow down on unhealthy choices the minute I get home. Now I always have a protein shake in the car to drink so I am not ravenous when I walk in the door. Mistakes and failures are the fertile soil in which success springs up! Never feel guilty for slipping - just turn it into a positive learning experience.
Think about what triggered you to eat the chocolate. Were you emotional about something? Were you hungry or tired? Where did it happen and what was the circumstance? Is it something you had a home or were you elsewhere? Were you alone or with someone? Once you figure out what triggered the behavior, you can make a plan to ensure success next time.
Remember that any one of us can fall into the pit, given a moment of weakness combined with temptation. We have to set up guard rails that either 1) keep us strong (like having a protein shake in the car) or 2) keep us back from the edge of temptation (not having chocolate in the house).