catch any error when saving a function