API16

JError/customErrorPage

From Joomla! Documentation

< API16:JError

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Display a custom error page and exit gracefully


<! removed transcluded page call, red link never existed >

Syntax[edit]

static customErrorPage(&$error)
Parameter Name Default Value Description
&$error $error object

Returns[edit]

void

Defined in[edit]

libraries/joomla/error/error.php

Importing[edit]

jimport( 'joomla.error.error' );

Source Body[edit]

public static function customErrorPage(& $error)
{
        // Initialise variables.
        jimport('joomla.document.document');
        $app            = & JFactory::getApplication();
        $document       = & JDocument::getInstance('error');
        $config         = & JFactory::getConfig();

        // Get the current template from the application
        $template = $app->getTemplate();

        // Push the error object into the document
        $document->setError($error);

        @ob_end_clean();
        $document->setTitle(JText::_('Error').': '.$error->get('code'));
        $data = $document->render(false, array (
                'template' => $template,
                'directory' => JPATH_THEMES,
                'debug' => $config->getValue('config.debug')
        ));

        JResponse::setBody($data);
        echo JResponse::toString();
        $app->close(0);
}


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]