error_prepend_string
AKA "Dark Mode Errors"
This module allows a Drupal website to incorporate the directives error_prepend_string and error_append_string defined in php configuration. This will allow site maintainers to insert text strings into error pages. This can be used to add additional styling to these error messages to improve the visual aesthetic and readability of error messages. You can use a configuration like this to create a "dark mode" version of error pages:
[PHP]
error_prepend_string= "<style>@media (prefers-color-scheme: dark) {* {background-color: black;color: #ff6b6b;font-family: monospace;font-size: 1.2em;}}@media (prefers-color-scheme: light) {* {background-color: white;color: red;font-family: monospace;font-size: 1.2em;}}</style>";"
With the "prefers-color-scheme" media query, if a user has their system preferences set to use dark themes, this will display a black background, with light red text for the error. Also with slightly larger font.
Note, this module will only work for errors from thrown exceptions. if you also want to implement this for fatal errors, these are handled by Drupal core's error handler, then you will need to implement a patch to core on your site. This issue #3518839: Use php configs error_prepend_string and error_append_string provides the patches needed for Drupal 10.x and 11.x. You can apply these via composer using the cweagans/composer-patches. If you are not using composer to manage your Drupal project, it is highly recommended that you do!
You will also need access to modify your php.ini configuration. this is easily done in ddev.
Similar modules
If a more elaborate theme for error pages is what you are after, then you should look into the Error custom pages module, which will allow you to have better themed error pages.