Animation length

I have script:

    public Animator anim;
    ...
    anim = anim.GetComponent <Animator> ();
    float animationlLength = anim.animation.clip.length;

I drag object that has animator component to the script in the inspector.

I get error:

MissingComponentException: There is no ‘Animation’ attached to the “Hand” game object, but a script is trying to access it.
You probably need to add a Animation to the game object “Hand”. Or your script needs to check if the component is attached before using it.

You can use Event in the last frame of the animation.