Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module allows you to add custom text and styling to error pages by utilizing PHP's `error_prepend_string` and `error_append_string` configurations. This can be used to style error messages, for example, to create a "dark mode" appearance for users who prefer it. It works for errors from thrown exceptions and may require a core patch for fatal errors.

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.

Activity

Total releases
2
First release
Apr 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Release date
1.0.1 Stable Apr 19, 2025
1.0.0 Stable Apr 15, 2025