Don't try and add a class on error, as this causes an UnboundLocalError to occur