moved deciding whether to log errors to an earlier point