Catch errors when getting context