我们如何限制管理员以外的用户查看所有php错误?

We have errors showing up in some pages. These errors must be shown only for admin users.

I changed the "Error message to display" as none. Still the errors are showing up. I copied status-messages.html.twig to my theme and tried to give is_admin. That is giving me error. Any help would be appreciated.

{% block messages %} 
  {% if message_list is not empty %} 
    {{ attach_library('bartik/messages') }} 
    <div class="messages__wrapper layout-container"> 
      {{ parent() }} 
    </div> 
  {% endif %} 
{% endblock messages %} 

Error display should only be enabled on a development copy of the website. Even if you hide errors from displaying for some users, there is a good chance the errors can be accessed somewhere from within developer tools (and can pose a huge security risk.) So, the option to disable error display is not available by default 'per user', because the standard pattern is to:

  1. Disable showing errors on production site (under Configuration > Logging and Errors.) Review error logs to gain insight into failures.
  2. On your local / dev environment, add the following to sites/default/settings.local.php to have error showing enabled in that environment

$config['system.logging']['error_level'] = 'verbose';

This way, when you import your installation into dev from live, error display will be enabled by default without any tinkering. A "set-it and forget it" config.

A good article on the subject, with details on debugging Twig properly can be found at https://www.drupixels.com/blog/enable-drupal-8-debugging-mode-and-error-reporting-local-development.