catching and logging exception