unexpected error and ErrorDocument 500 template

Author Message

Jean-Raphael Frydman

Thursday 21 October 2010 3:06:01 am

Hello,

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...

sincerely,
Jean-Raphael

André R.

Thursday 21 October 2010 4:47:39 am

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?

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jean-Raphael Frydman

Thursday 21 October 2010 5:16:56 am

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 ?

thanks

JR

André R.

Thursday 21 October 2010 7:49:03 am

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.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jean-Raphael Frydman

Monday 25 October 2010 3:28:21 am

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() )
//[...]

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.