. add error logging when exception
. change the way that final errors got logged