So, you're doing TDD. You're pretty happy with the results. You have confidence. You're refactoring. You're having fun.
Then someone finds a bug. In your code. Your ego deflates, you collapse in depression. Maybe this TDD thing isn't going to work. Better tell your boss to hire back all the testers he just fired.
Nah, TDD isn't about producing code with no bugs. After all, its about Development not about Testing. Buck up & get back to work. Here's my approach:
Now comes the really important bit: the learning. Think about why this bug happened; what thinko resulted in this broken behavior. Don't scold yourself, just understand it. Now, free yourself from the burden of this bug by using your new understanding to improve the unit tests you write in the future.
There, now you've debugger the code and yourself!