abstracted a `wrapInTryCatch` function