It's easy to overlook errors when designing a user experience; they shouldn't happen when the UX is good enough, right? In reality, errors happen, and they happen often. But the way your system responds to these errors is as critical to the user experience as how your system acts when things are going well.
Remember, it's at this point your user is already frustrated, don't make the situation any worse by handling it poorly. In fact, errors can be an opportunity to strengthen your relationship with the user; the humour example in this article would probably make me enjoy the "finding a unique username" loop, or a least make me forget that this is usually a painful process.
Think of your error message as a conversation with your user — it should sound like they’ve been written for humans.