I am trying to understand when a morphism defined in an open dense subset of a variety can be extended to the whole variety.

For curves, it is known that if f:C->C’ is a rational morphism from the curve C to the curve C’ then f can be uniquely extended to the whole curve C.

On the other hand, for higher dimensional varieties the situation is more complicated, for instance,one can not extend a morphism from $\mathbb{A}^2\setminus(0,0) \to \mathbb{P}^2$.

I would like to know if is there any “nice” condition on a morphism $f:U \subset X \to Y$ where U is a open dense subset of a (smooth, if necessary) projective variety X, and Y is a projective variety, that make possible to extend $f$ to the whole X.

Thank you in advance.