Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Error prepend string

No security coverage Drupal 8–11
View on drupal.org

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.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

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

Releases

Version Type Core Release date
1.0.1 Stable 8–11 Apr 18, 2025
1.0.0 Stable 8–11 Apr 15, 2025