Solution
= Solution
The integrand has an order-two <pole> at $0$ and a simple pole at $2$. Write it near zero as $h(z)/z^2$, where
$$
h(z)=\frac{z^2+e^z}{z-2}.
$$
Its <residue> at zero is
$$
h'(0)=\left.\frac{(2z+e^z)(z-2)-(z^2+e^z)}{(z-2)^2}\right|_{z=0}
=-\frac34.
$$
At $z=2$ the residue is
$$
\frac{2^2+e^2}{2^2}=1+\frac{e^2}{4}.
$$
The <residue theorem> now gives
$$
\boxed{
g(x)=\begin{cases}
-\dfrac{3\pi i}{2},&0<x<2,\\[4pt]
\dfrac{\pi i}{2}(1+e^2),&x>2.
\end{cases}}
$$