How is the error calculated in the measurement tool

I am calculating length using the measurement tool. It gives a reading like measurement ± error. I would like to know how is the error calculated?

That’s a pretty simple calculation.

MEAN_ERROR_FACTOR = MIN_EARTH_RADIUS / MAX_EARTH_RADIUS
distanceError = distance * (1 - MEAN_ERROR_FACTOR)