Check that err is defined before performing any op