If you are ever working with code in Drupal and encounter the typical message, "The website encountered an unexpected error. Please try again later," it’s a sign that there’s a bug. However, there’s no way to know exactly where it occurred, and it's tedious to go back and forth trying to find it manually. Drupal has an error level manager to help display errors.
The following tip is a trick developers can use to make the most obvious errors visible.
All you have to do is copy the following code.
And paste it into the "settings.php" file of your Drupal installation.
The code can be placed anywhere in the settings.php file; in this example, it was pasted at the end.
Save the changes and return to the broken page, and you should now see that the error will be visible on the page.
Once the code causing the error is fixed, reload the page, and it should be resolved.
Very important: perform this action only in local environments, as doing it in production could expose important server information to potential attackers.
Video credits: https://www.youtube.com/watch?v=Mem8nxlBJ0I&ab_channel=OSTraining