2

When there's an error with the Database, Joomla throws that error. It takes place so early in the execution cycle that nothing from the Joomla application is ready, so you get an ugly blank page with the error message in simple text.

Is there a way to override that so these errors are directed for example to a static HTML error page? I already checked this

https://docs.joomla.org/Custom_error_pages

but if I'm not wrong this won't work for these errors, as it requires more stuff being properly loaded, which is not the case.

Thanks in advance!

1

Sorry about the late answer.

Yes, it is possible to do so, but you will need to do a small edit on Joomla's main index.php file located in the root installation directory.

Brief explanation: this error message is actually an Exception thrown by the method getApplication of Joomla's core class JFactory. So you can't simply customize the error message without touching Joomla core a little.

Quick solution: All you need to do is a try - catch when the method getApplication is called. To do so, open the file index.php located at your root installation directory and search for something like $app = JFactory::getApplication('site'). Then replace it by the lines below:

try {
    $app = JFactory::getApplication('site');    
}
catch (Exception $e) {
    // Do something when the site cannot be instantiated.
    header('Location: my-error-file.html');
}

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.