// Since #pre_render, #post_render, #lazy_builder callbacks and theme
// functions or templates may be used for generating a render array's
// content, and we might be rendering the main content for the page, it is
// possible that any of them throw an exception that will cause a different
// page to be rendered (e.g. throwing
// \Symfony\Component\HttpKernel\Exception\NotFoundHttpException will cause
// the 404 page to be rendered). That page might also use
// Renderer::renderRoot() but if exceptions aren't caught here, it will be
// impossible to call Renderer::renderRoot() again.
// Hence, catch all exceptions, reset the isRenderingRoot property and
// re-throw exceptions.
try{
return$this->doRender($elements,$is_root_call);
$context=$this->getCurrentRenderContext();
if(!isset($context)){
thrownew\LogicException("Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead.");
}
catch(\Exception$e){
// Mark the ::rootRender() call finished due to this exception & re-throw.
$this->isRenderingRoot=FALSE;
throw$e;
if($is_root_call){
trigger_error('render() with $is_root_call is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use renderRoot() instead. See https://www.drupal.org/node/3497318.');
// Abort, but bubble new cache metadata from the access result.
$context=$this->getCurrentRenderContext();
if(!isset($context)){
thrownew\LogicException("Render context is empty, because render() was called outside of a renderRoot() or renderInIsolation() call. Use renderInIsolation()/renderRoot() or #lazy_builder/#pre_render instead.");