swap error function.