Since $e^{iz}$ is small in the upper half plane but large in the lower, and $e^{-iz}$ is small in the lower half plane but large in the upper, you cannot handle both terms with the same contour, thus you must separate the two parts, and that means you get a pole in $z = 0$ for the integral. Thus you must treat the pole somehow. One way is to shift the contour of integration away from the real axis like robjohn did. Another way is to treat the integral as a principal value integral.

Since the integrand is real, we have

$$\begin{align}
\int_{-\infty}^\infty \frac{\sin x}{x}\,dx &= \operatorname{Im} \operatorname{p.v.} \int_{-\infty}^\infty \frac{e^{ix}}{x}\,dx\\
&= \operatorname{Im} \lim_{\varepsilon\searrow 0} \int_{\lvert x\rvert \geqslant \varepsilon} \frac{e^{ix}}{x}\,dx\\
&= \operatorname{Im} \lim_{\substack{\varepsilon\searrow 0\\ R\nearrow\infty}} \int_{\varepsilon \leqslant \lvert x\rvert \leqslant R} \frac{e^{ix}}{x}\,dx,
\end{align}$$

which allows us to consider only one exponential for the sine.

To compute the latter integral, we close the contour by adding a semicircle $C_\varepsilon$ of radius $\varepsilon$ around $0$ in the upper half plane, and either a semicircle of radius $R$ around $0$ in the upper half plane, or three straight line segments connecting $R,R+iR$, $R+iR,-R+iR$ and $-R+iR,-R$ respectively; call the latter contour $C_R$, whichever of the two you choose. Let $C$ be the closed contour obtained from joining the two intervals on the real axis, $C_\varepsilon$ and $C_R$. Since the integrand is holomorphic in a neighbourhood of the region bounded by $C$, Cauchy's integral theorem asserts

$$\int_C \frac{e^{iz}}{z}\,dz = 0,$$

and hence

$$\int_{-\infty}^\infty \frac{\sin x}{x}\,dx = -\operatorname{Im} \lim_{\substack{\varepsilon\searrow 0\\ R\nearrow\infty}} \left(\int_{C_R} \frac{e^{iz}}{z}\,dz + \int_{C_\varepsilon} \frac{e^{iz}}{z}\,dz\right).$$

By Jordan's lemma, or an elementary estimate if we chose the rectangular $C_R$, we have

$$\lim_{R\to\infty} \int_{C_R} \frac{e^{iz}}{z}\,dz = 0.$$

Parametrising $C_\varepsilon$ by $\varepsilon\cdot e^{i(\pi-t)}$, we see

$$\lim_{\varepsilon \searrow 0} \int_{C_\varepsilon} \frac{e^{iz}}{z}\,dz = -\pi ie^{i\cdot 0} = -\pi i,$$

and hence overall

$$\int_{-\infty}^\infty \frac{\sin x}{x}\,dx = \pi.$$