Consider a function $f$ defined on the real line. Consider the restriction of the function to the interval $[-L,L]$ and periodically extend the function using a Fourier series $$f_L(x) = \sum_{n=-\infty}^\infty \hat{f}(k_n)e^{ik_nx}$$ where $k_n=\pi n/L$ and where $\hat{f}(k_n)$ denotes the Fourier coefficient. For sufficiently large $L$, it seems plausible that we may approximate the Fourier series with an integral. In particular, let us extend $\hat{f}(k_n)$ to non-integral values through $$\hat{f}(k)=\frac{1}{2L}\int_{-L}^L f_L(x)\,e^{-ikx}\ dx $$ and write the approximation as $$\tilde{f}_L(x)=\frac{2L}{(2\pi)}\int_{-\infty}^\infty\hat{f}(k)\,e^{ikx}\ dk$$ To provide a bit of context, I first encountered such integral approximations when studying cosmology. It seems common in physics to take such approximations where we formally make the replacement $$\sum_{n=-\infty}^\infty \longrightarrow \frac{2L}{(2\pi)}\int_{-\infty}^\infty$$ in the limit of large $L$, which is called the continuum limit.
My question is under what conditions is such an approximation valid? What kind of smoothness and regularity conditions need to be placed on $f$? How well does $\tilde{f}$ approximate $f$ on $[-L,L]$ (for sufficiently large $L$)? Are there any error bounds?