Merge "Fix a bug where error count was reset before returning it." into tm-dev