catch errors when calling callbacks