Consider the integral $\int_{-\infty}^\infty \frac{1}{x+i \epsilon}\, dx$, where $\epsilon$ is a positive real number. We can evaluate the integral by closing the contour in the complex plane and then applying Cauchy's residue theorem.
Notice that $1/z$ converges to $0$ at infinity, and is analytic everywhere except at $z=0$. This means that if we close the contour in the upper half complex plane, the integral is zero, while if we close it in the lower half complex plane, the integral is non-zero. Where have I gone wrong?