Catch errors and print them to the logger