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!

2 Answers 2

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');
}
0

I had also this type of error I just change PHP version from Cpanel and the site is now working fine

2
  • Welcome to JSE and thank you for contributing. The system has auto-flagged this answer as low-quality because of its length -- typically very short answers are not very helpful to future researchers. After reading your answer, I can agree that this answer is not high quality because it is very vague about the alleged resolving advice. Which PHP version(s) did you experience this error with? In conjunction with which Joomla version? Which PHP did you change to as a means to a resolution? You may edit your post at any time and as often as you need. Commented Mar 13, 2022 at 0:19
  • Please take our tour, consider giving your account a non-anonymous screenname and read How to Answer. Commented Mar 13, 2022 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.