The paper discusses the influence of the geometry of a Hartmann-(Shack) wavefront sensor on the total error of modal wavefront reconstruction. A mathematical model is proposed, which describes the modal wavefront reconstruction in terms of linear operators. The model covers the most general case and is not limited by the orthogonality of decomposition basis or by the method chosen for decomposition. The total reconstruction error is calculated for any given statistics of the wavefront to be measured. Based on this estimate, the total reconstruction error is calculated for regular and randomised Hartmann masks. The calculations demonstrate that random masks with non-regular Fourier spectra provide absolute minimum error and allow to double the number of decomposition modes. © 2005 Optical Society of America.