简体   繁体   中英

Fatal error class 'JError' not found

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

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.

eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM