Error handling - detect null elements