Catch errors in resource callback