The most useful general criterion for extending analytic subsets of an open subset of a manifold to the whole manifold is :
Theorem of Remmert-Stein
Let $X$ be an analytic space (for example a complex manifold), $Z\subset X$ a closed analytic subspace of dimension $\lt n$ and $A\subset U$ a purely $n$-dimensional closed analytic subset of the open set $U=X\setminus Z\subset X.$
Then the closure $\bar A\subset X$ is an analytic subspace of $X$.
So the "reason" for the failure of extension in your example is that your $Z$ is too big: it is a line of dimension one and your analytic subset , the graph of the exponential function, has dimension one as well, so that its closure in $\mathbb P^2 $ is no longer analytic.
However if you delete a point $Q\in \mathbb P^2 $ then any analytic curve $C\subset \mathbb P^2 \setminus \lbrace Q \rbrace$ will have analytic (even algebraic) closure $\bar C\subset \mathbb P^2$
In a comment below Dima asks about extending an analytic subset of $A\subset \mathbb A^2(\mathbb C)$ to $\mathbb P^2(\mathbb C)$, a situation where Remmert-Stein's theorem doesn't apply .
By Chow's theorem $\bar A \subset \mathbb P^2 $ is analytic iff it is algebraic, and in that case $A\subset \mathbb A^2$ is algebraic too, so that finally $A$ is extendable iff it is algebraic.
The simplest obstruction against algebraicity of $A$ might be that a line in $\mathbb A^2$ not contained in $A$ intersects $A$ only in finitely many points.
In Dima's example where $A$ is defined by $y=exp(x)$ , the line $y=1$ intersects $A$ in infinitely many points, which is an obstruction against $A$ being algebraic and thus explains why $A$ is not extendable to $\mathbb P^2$