Error handling

Chapters

In Gentics Portal Node PHP several situations can cause and error, in which error handling should be:

  • HTTP errors – 401, 403, 404.
  • PHP Exceptions, YII Exceptions (generated by yii core).
  • PHP errors: notices, warning.
  • PHP critical errors: parse error, compile error, core error

HTTP errors. Occurred when user is not authorized, has no access, content not available, executes bad request (hack). *For these types of errors the portal is redirecting to a page specified in the configuration (keys e401, e403, e402 respectively), otherwise depending on module logic

PHP Exceptions, YII Exceptions. PHP errors: notices, warning.

  • For these types of errors user is redirected to specified page in configuration (key e500).
  • Write error to file custom/runtime/error.log (can be changed to DB log), send mail notification.

PHP critical errors: parse error, compile error, core error.

  • In this situation user can’t be redirected because the error handler is executed only after headers are already sent. But the error is written to the log and an email could be sent to the admin.

For:

  • HTTP errors
  • PHP Exceptions, YII Exceptions

Displaying of errors will depend on the configuration of the constant YII_DEBUG in file frontend/www/index.php. If set to true, it shows all errors in browser, otherwise (usually in production mode) a redirect to some error page with user friendly description will happen, the error will be saved in the log and an email could be sent to the admin.

Configuration example:


'errorHandler' => array(
            'errorPages' => array(
                'e400' => array(
                    'en' => '/site/error400',
                ),
                'e403' => array(
                    'en' => '/site/error403',
                ),
                'e404' => array(
                    'en' => '/Content.Node/error/404.en.html',
                    'de' => '/Content.Node/error/404.de.html'
                )

                //for system exceptions, php notices warnings
                'e500' => array(
		            'en' => '/Content.Node/error/500.en.html',
                ),
            )
        )

Error 403 will also be used in case if you’re logged in and your user is not allowed to access a content (based on permissions).