handle exceptions in heartbeat thread