Hot answers tagged

18

As @DmitryRekun said, a good discussion is here. The key piece to consider in all of this is what type of error do you have? There are two types of errors: Recoverable Unrecoverable. The difference I tend to sum up as follows: Can I still show the page that was requested, even though this error occurred? Yes? - Recoverable No? - Unrecoverable Now that ...


12

Here is how I'm managing an errors. View or Controller try { $this->item = $this->get('Item'); } catch (Exception $e) { if ($e->getCode() == 404) { // Not found throw new Exception($e->getMessage(), 404); } // Generic errors JFactory::getApplication()->enqueueMessage(JText::_('...


7

You can use enqueueMessage to display errors, for example: $user = JFactory::getUser(); if ($user->guest) { $msg = 'You must be logged in'; JFactory::getApplication()->enqueueMessage($msg, 'error'); // red JFactory::getApplication()->enqueueMessage($msg, 'warning'); // yellow JFactory::getApplication()->enqueueMessage($msg, ...


5

Because of "return false", you are taken back to the model, so "Save failed with the following error:" message is displayed. If you don't want to go back to the model, you can redirect user back to your form directly instead of entering the model, then the controller and finally your form view. But because you go away from the model and the controller, ...


4

Most code blocks like this can simply be replaced with enqueueMessage since they are not actually acting on the error and simply using JError to print them out. // Check for errors. if (count($errors = $this->get('Errors'))) { foreach($errors as $error) { JFactory::getApplication()->enqueueMessage($error, 'error'); } }


3

There is no alternative to JError and JException classes, Joomla development decided to remove those classes and use php exception instead. Take a look at the deprecated JError table. So on my opinion you have two possible ways: Rewrite your plugin with php exception handler Rethink your plugin using JLog class Here are some interesting discussions and ...


3

You should probably throw an exception. JError was deprecated in Joomla 3.0 throw new Exception(JText::_('COM_MYCOMP_ERROR_MESSAGE_NOT_FOUND'), 403);


3

You should use PHP Exceptions instead. I do find it odd that Joomla throws deprecated messages when using JError yet isn't still used in the 3.3.6 core. Anyway, the below would be an example of Exceptions for a database query $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName(array('username'))) ->from($...


2

It appears that you don't yet have your file path properly declared. I'll offer some instructions to correct your tmp path, but you should execute the same technique to eliminate the other Warnings too. If you have access to your administrator backend: Go to System > Global Configuration > Server (tab). The Path to Temp Folder field should read something ...


2

These are not Errors, these are only Warnings (or is there also any error message connected to these particularly?). This warning usually happens when (due to ie. migration) a file path was changed and the ROOT or BASE path is different than it was before. in Joomla in 'Admin->Global configuration' if you set 'Error Reporting' to 'system default', then these ...


1

Yes, it's still being deprecated. JError::raiseError() should be replaced with native exceptions. JError::raiseWarning() and JError::raiseNotice should be replaced with calls to application's enqueueMessage() method to display warnings/notices. See Potential backward compatibility issues in Joomla 4 for code migration tips.


Only top voted, non community-wiki answers of a minimum length are eligible