$\def\Res{\operatorname{Res}}\def\Re{\operatorname{Re}}$ First solution: Complex function $f(z)=\frac{\cos z}{1+z^2}$ has a pole $z=i$ on the upper complex plane. $\Res (f,i)=\frac{e+1/e}{4i}$, so $$ \int_{-\infty}^{\infty}\frac{\cos x}{1+x^2}dx=2\pi i\Res (f,i)=\frac{\pi}{2}(e+1/e) $$
However, this integration is in fact $\frac{\pi}{e}$. Here is another solution.
Consider complex function $g(z)=\frac{e^{iz}}{1+z^2}$. $\Res (g,i)=\frac{1}{2ie}$ and $\frac{\cos x}{1+x^2}=\Re (g(x))$ when $x$ is real. $$\int_{-\infty}^{\infty}\frac{\cos x}{1+x^2}dx=\Re (2\pi i\Res (g,i))= \frac{\pi}{e} $$
Why is the first solution wrong?