Making mistakes and correcting them is a part of experience. So all it matters is that, “Do not repeat a mistake”. Make note of all the mistakes or possibly document it. We might think that no one is naive enough to make that mistake again, but trust me there will be someone soon following your foot steps and have invested enough time solving it.
Effective debugging and pin pointing the error comes with experience. (Not always, most of the time). The most important thing I have noticed in software engineering is ‘keeping things simple’. In the process of solving bug, I have patched the code here and there and in the end, things become complicated and lose their focus on the prime goal.
Always, when there is a bug, take a step back and understand the requirement. Add enough test cases and tests to see if it coves all the base case and edge cases. Then start working towards building code or revising your own code and then simple step would fix the issue. Also its better to time your efforts as it gets easy to get lost in a rabbit hole.
Reaching out for help is not considered as you are not capable of solving the issue but in turn is viewed as a wise decision in saving your time (time is valuable) and also there is a high chance that you have missed a key point, or might get a hint on which direction you should look at. Also it helps for your team member to understand your strengths and there will be a collaborative efforts. If there is no message or update from you that whole day, it will look as if like “you are on your own”.
Effective communication and team efforts, saves the day.