cache and record error; modify function return