adding error handler

need to work out when vertex not found aka loop cannot complete.