JError is shown as deprecated (as of 12.3), but is still widely used in the core. The API docs say that its status is deprecated - 4.0 Will be removed without replacement, but its still alive and well in 4.0.0 Alpha 1. Is it still being deprecated?

If it truly is deprecated and we are supposed to stop using it, what is the alternative for the following situation. In the save method of a component model subclassing JModelAdmin, and you want return false to indicate that there was a problem with the data, how do you add a message to the error box?


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.

  • How can throwing native exceptions work in the context I've described? When you're in your components model's save method, and you've parsed the input and found it to be in error and want to redisplay the form to the user with an error message at the top, then throwing an exception will not achieve this. Also, the core of 4 is still using JError to do exactly what I'm describing. – Dom Dec 8 '18 at 20:09
  • Use application's enqueueMessage() method to display warnings/notices. – Sharky Dec 9 '18 at 12:10
  • Also, if you're testing J4 always use the latest nightly build. I can't confirm that JError is present in current nightly. – Sharky Dec 9 '18 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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