Learning when things go wrong