EntityMetadataWrapperException when accessing empty entity body. How can I test if body is empty first? The following call

$body = $entity-&gt;body-&gt;value-&gt;value();


throw the following error

EntityMetadataWrapperException : Unable to get the data property value as the parent data structure is not set. dans EntityStructureWrapper-&gt;getPropertyValue()


when the body is empty.

How can I prevent it?
Just simply see the value is empty

if($node_wrapper-&gt;body-&gt;value() != ""){
 //Evaluates true
}


or use a try catch

try{
 echo $entity-&gt;body-&gt;value-&gt;value();
}catch(Exception $e){
  echo "Value does not exist continue";
}