tal:on-error

This attribute replaces the tag by the tal:on-error expression evaluation if a path error is detected in the tag content, or if any PHP exception is thrown in the tag content.

<span tal:on-error="string:No username defined here"
      tal:content="user/name">the user name here</span>

If an error occurs accessing 'name' or 'user', the error string will be shown at the tag's place.

This also works on more than one level of template:

<span tal:on-error="string:error occurred somewhere">
  <span tal:content="user/firstname"/>
  <span tal:content="user/lastname"/>
  <span metal:use-macro="userMenu" />
</span>