As the old adage goes, "an ounce of prevention is worth a pound of cure", and it's especially pertinent when it comes to software bugs. The first two questions are OK, but to any experienced coder they are automatically considered part of fixing the bug and not afterthoughts. The third question, "What should I do to prevent bugs like this?", is especially important because once you learn to identify where and how bugs can occur you can markedly decrease their occurrence, which makes everyone involved happier.
I found this article and some others from the same guy eight or nine years ago. I lost the links and had tried very hard to find them again without any luck. The name got confused with Don van Vliet in my mind. In particular I loved this piece: http://www.multicians.org/andre.html because something very similar happened to me at the time. Thank you very much to prakash for bringing it back to me :-)
Number 3 is especially relevant. It gives weight to the adage that "Success is learning to improve with each failure."
Whenever I make a mistake, especially a big one, I like to stop and think, "is this mistake a result of process. Is there an improvement or a best practice I could follow?"
Simplistic for an experienced developer. But this is the approach I find myself taking when I'm working with an inexperienced programmer or intern. It helps to ask "why" over and over.