Catch exception made in the run function and log it.