In this paper, we propose a novel sparse recovery method based on the generalized error function. The penalty function introduced involves both the shape and the scale parameters, making it very flexible. The theoretical analysis results in terms of the null space property, the spherical section property and the restricted invertibility factor are established for both constrained and unconstrained models. The practical algorithms via both the iteratively reweighted $\ell_1$ and the difference of convex functions algorithms are presented. Numerical experiments are conducted to illustrate the improvement provided by the proposed approach in various scenarios. Its practical application in magnetic resonance imaging (MRI) reconstruction is studied as well.