This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Install & configuration » unexpected error and ErrorDocument...

unexpected error and ErrorDocument 500 template

unexpected error and ErrorDocument 500 template

Thursday 21 October 2010 12:06:01 pm - 6 replies


I'm trying to use a template for the error 500. The problem is when the mySQL server is stopped, eZpublish show the error 500 page : "An unexpected error has occurred. Please contact the webmaster." even if I specify a template for the error 500 like the 404.tpl

I've tried to use the ErrorDocument 500 in the .htaccess file (which is allowed in the virtual host) but it doesn't work.

If you have any idea...


Thursday 21 October 2010 1:47:39 pm

That error is using and exception and not template, so you can't override the view of those I'm afraid.

Do you often have to turn of your sql server for some reason?

Thursday 21 October 2010 2:16:56 pm

Hello André,

In case the SQL server crashes, it would be better to have a userfriendly page than the error message on a blank page.
Is there any way to catch the exception and to send another page ?



Modified on Thursday 21 October 2010 3:02:11 pm by Jean-Raphael Frydman

Thursday 21 October 2010 4:49:03 pm

you can try by using ouput filter, but don't think the exception is currently catched so think you'll need to hack index.php and do that your self if you need it.

Monday 25 October 2010 12:28:21 pm

Well, it almost works.

I have put this code in lib/ezutils/classes/ezexecution.php from line 195, in the defaultExceptionHandler function

what do you think ?
I still have some problems with the include of img in the html source, maybe a rewrite rule in the apache vhost config file.

static public function defaultExceptionHandler( Exception $e )    
{        if( PHP_SAPI != 'cli' )        
            header( 'HTTP/1.x 500 Internal Server Error' );
            header( 'Content-Type: text/html' );
          if ( $documentRoot )
             self::$eZDocumentRoot = $documentRoot;            }
             else if ( self::$eZDocumentRoot === null )
             self::$eZDocumentRoot = getcwd();            }
            chdir( self::$eZDocumentRoot );
            $stringerror = file_get_contents('./errorpages/erreur_500.html', true);
            $splitString = str_split($stringerror, 8192);
            foreach($splitString as $chunk)
                echo $chunk;
           if( eZDebug::isDebugEnabled() )

Modified on Monday 25 October 2010 12:32:42 pm by Jean-Raphael Frydman

Monday 05 November 2012 6:10:00 am

I'm having this exact same issue. My ErrorDocument definition in my VirtualHost config doesn't seem to be being trigger by the eZ Publish database exception.

I'd rather not hack the kernel code to display my own error message.

Did you find a resolution for this?

Monday 05 November 2012 11:23:38 am

@Josh it seems that the ErrorDocument directive in Apache is completely unrelated to the workings of php (ie. it can not be used to execute different actions when php returns a response with http return codes indicating errors):


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from