31

I get this error with Drupal 7.

The website encountered an unexpected error. Please try again later.

How can I get more information about this error? Is there any report or log to understand what happened? The PHP log doesn't report errors.
How can I disable that message and have a more useful one for debugging purpose?

12 Answers 12

29

This error comes from an uncaught PHP exception. Drupal catches exceptions so no ugly PHP error message is displayed to user. You can find the exception info in the 'Recent log messages' link on Reports (or try this path: /admin/reports/dblog). Make sure 'Database logging' module is enabled because this module provides this report.

You will see all the internal messages that have been generated. Filter by type 'PHP' and Severity 'error' and you'll probably find a message about an uncaught exception. This is causing your problem. Now you have more information so you may be able to fix it.

| improve this answer | |
  • Ok thanks, so is there no out-of-the-box way to change this behaviour to a more debug-compliant one ? (such as... displaying the exception on the screen) – theredled Nov 7 '12 at 11:58
  • No, AFAIK there's no easy way to do that. You may try setting your own exception handler (using standard PHP function set_exception_handler) but beware of side effects. – sanzante Nov 7 '12 at 12:09
  • 8
    Great idea to check /admin/reports/dblog. Unless, of course, you can't even login because this stupid error has hosed your entire drupal site! – g33kz0r Feb 3 '13 at 1:45
  • Myself, saw this error with viewreference "FieldException: Attempt to create a field of unknown ..." The solutionfor me enabling drush en viewreference worked - I'm working with other people and pulling their git updates so I get the module code but I need to enable the module (as the enable is in the database, which I'm not getting in the pull request, we're using Features). Hope this helps other folks. – therobyouknow Dec 2 '13 at 9:52
  • 4
    @g33kz0r: You can use the drush watchdog-show to see the error messages or if your site is completely broken check the watchdog table in the database where those messages are stored. – sanzante Sep 11 '14 at 11:08
16

Drupal 6 & 7

If using Drush, just do drush vset error_level 1.

Otherwise, go to "/admin/config/development/logging" and change the setting to "Errors and Warnings"

Drupal 8

Instead of drush vset/vget/vdel, you can use cset/cget/cdel for config values and sset/sget/sdel for state values.

| improve this answer | |
15

EASY WAY for Drupal 8,

if you can't login anymore to access the recent log messages as described in the accepted answer.

Open the file /sites/default/settings.php with an editor or ftp client and add this line:

$config['system.logging']['error_level'] = 'verbose';

After reloading the page you will see a full error message, instead of the generic “The website encountered an unexpected error. Please try again later.”

| improve this answer | |
  • fastest/easiest method for me – rjkunde Mar 23 at 22:59
13

EASY WAY

Edit your settings.php and add a line there (especially on your dev site, you can just keep this on)

$conf['error_level'] = 1;

drush requires you being able to bootstrap the database.

| improve this answer | |
  • The BEST answer. It saved my time. – Austin Jan 27 '19 at 6:25
3

That error comes from _drupal_log_error().

As a quick fix for development you could update that function to provide more verbose error messages, but make absolutely sure you change it back before the site goes live :)

| improve this answer | |
0

Check the dblog. Its the best place to find errors in a Drupal webite. Also check the JS console to pick out additional errors in your browser.

| improve this answer | |
  • Thanks for dblog ( /admin/reports/dblog ). Now, how can I disable that message and have a more useful one for debug purpose ? – theredled Nov 7 '12 at 9:41
  • 1
    Anyway, I don't think that a JS error could cause that server error... – theredled Nov 7 '12 at 9:42
  • Console will let you know if it is 500 or something. – Sahu V Kumar Jan 17 at 11:41
0

Check in the watchdog table in MySQL. You can download the Blob (the variables column) and open it with Notepad. It will show you a serialized object with your error.

| improve this answer | |
0

Try this:

error level

admin menu equivalent: admin/config/development/logging
drush command: drush vset -y error_level <value>
values:
    0: none
    1: errors and warnings
    2: all 
| improve this answer | |
0

To make errors visible on your Drupal website, find the index.php file in the main directory of your site. Open index.php and add this code directly before the very first line of the file:

error_reporting(E_ALL); 
ini_set('display_errors', TRUE); 
ini_set('display_startup_errors', TRUE); 

You may also try to Solving Drupal Problems With Error Logs as described here..

| improve this answer | |
0

This is an old thread but as I encountered this same issue recently providing my inputs. I was not able to access any of the Drupal paths as I was always getting this error no matter what. This started happening after I made an update to a view so I knew what was needed to be done but I was not able to open the view. Thus I looked into Apache server logs. Apart from the solution given above such as looking at drush and dblogs it may be helpful instead to look into Apache server logs especially when you can not access any of the application paths. These are usually present under \logs\error.log file and will have the details on the unhandled exception and the place where its getting generated etc. As a quick fix you can comment the code which is throwing exception and make updates to the application. In my case I commented the code post that I was able to get to the view and make the updates needed. Hope it will help someone in some similar situations

| improve this answer | |
0

That is very interesting but if you open the page source (CTRL-U) then all the warnings and error messages is there, they are just in a hidden element. Search for element-invisible.

Edit: $conf['error_level'] = 1; should be placed in settings.php file as well.

| improve this answer | |
0

if you're installed any new modules may that modules are not compatible with your drupal please ensure those modules and remove and run again. Eg:i have installed page-layout module its not suitable with this then i have encountered this issue from browser after i have removed those modules from my project this works fine for me. in project loction select\modules\page-layout. remove unsupported directory from here. Thank you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.