Fix typo.
Add null check to avoid polluting $error.