0
votes

My website was running correctly before 2-3 weeks and now it gives me an error like: joomla fatal error class 'JError' not found . when i am typing the URL it shows the following error message... Fatal error: Class 'JError' not found in /home/dcmops/public_html/gu/libraries/joomla/factory.php on line 565

I am even not able to see the admin tab, it also shows the same error. Can anybody guide me regarding this issue...??

the code @ line 565 is as follows

if ( JError::isError($db) ) {
            header('HTTP/1.1 500 Internal Server Error');
            jexit('Database Error: ' . $db->toString() );
        }

        if ($db->getErrorNum() > 0) {
            JError::raiseError(500 , 'JDatabase::getInstance: Could not connect to database <br />' . 'joomla.library:'.$db->getErrorNum().' - '.$db->getErrorMsg() );
        }

        $db->debug( $debug );
        return $db;

Thanks & Regards, Rahul

1
Is the JError class file is included in this file? - Yogesh Suthar
@yogesh, I am new to PHP can you tell me how to check whether this file is included or not? - Rahul Singh
I'm not working on Joomla. And its having lots of inter file communication. You can ask this question to some Joomla expert here chat.stackoverflow.com/rooms/11/php - Yogesh Suthar
Which Joomla version are you using? - McRui

1 Answers

0
votes

If you are using Joomla 1.5, this will work fine. Otherwise you need to use standard Exceptions.

You can use a common function to handle all Joomla versions automatically.

Ex:

defined('APP_VERSION') or (version_compare(JVERSION,'1.6.0','ge') ? define('APP_VERSION', 2.5) : define('APP_VERSION', 1.5));

public static function throw_error($code, $msg){

  if(APP_VERSION == '1.5'){

    JError::raiseError( $code, $msg);
  }else{

    throw new Exception($msg, $code);
  }
}

Now you can throw exception just like JError.

e.g.

SomeClassName::throw_error(500, 'An exception occurred');