If ever while you are working with code an error occurs in Drupal and you get the typical message “The website encountered an unexpected error. Try it again later." it's an indicator that there is a bug but you have no way of knowing where it went and it's too long to go back and forth trying to find it, Drupal has a bug level manager to display.
The following tip is a trick developers can use to make the most obvious mistakes 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 is placed anywhere in the settings.php file, in this example it was pasted at the end.
The changes are saved and we return to the broken page and see that the error will now be visible on the page.
Once the code that is causing the error is fixed, we reload the page and it should be fixed.
It is very important to perform this action only in local environments as doing it in production can reveal important information about your server to potential attackers.
video credits: https://www.youtube.com/watch?v=Mem8nxlBJ0I&ab_channel=OSTraining