4

Is there any way to dispatch an event and call a method when an error is occurred in joomla same as Zend ? I want to log those error in log file. I want to use a single method to catch every error. is it possible ?

Is there any other way to do this except JError, Please suggest.

2 Answers2

1

To log errors to a file, you can use the following:

jimport('joomla.log.log');

// Log errors to specific file.
JLog::addLogger(
   array(
      'text_file' => 'mod_mymodule.errors.php'
   ),
   JLog::ALL,
   'mod_mymodule'
);

This will create the following and store all error there:

root/logs/mod_mymodule.errors.php

You can of course change mod_mymodule to whatever you wish.

Hope this helps

Lodder
  • 19,758
  • 10
  • 59
  • 100
0

If I understand your question right you can use JError class to get this done. You can raise error and handle them.

Techie
  • 44,706
  • 42
  • 157
  • 243
  • 1
    JError is deprecated though it is still used lots and lots of places where the switch to exceptions or messages has not been made. – Elin Mar 04 '14 at 11:56