Skip to content

Commit

Permalink
#534 Condtionally wire our exception handling to Joomla 4
Browse files Browse the repository at this point in the history
  • Loading branch information
amazeika committed Dec 7, 2021
1 parent 2535b7e commit cb43da9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions code/plugins/system/joomlatools/joomlatools.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public function __construct($subject, $config = array())
}

//Bootstrap the Koowa Framework
$this->bootstrap();
if ($this->bootstrap())
{
if (version_compare(JVERSION, '4', '>=') && Koowa::isDebug()) {
$subject->addListener('onError', array($this, 'onJ4Error'), Joomla\Event\Priority::ABOVE_NORMAL);
}
}

$this->onAfterKoowaBootstrap();

Expand Down Expand Up @@ -239,8 +244,10 @@ public function onBeforeRender()
* @see: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Application/CMSApplication.php#L296
* @return void
*/
public function onError($exception)
public function onJ4Error($event)

This comment has been minimized.

Copy link
@johanjanssens

johanjanssens Dec 10, 2021

Member

@amazeika Is there a specific reason to call this event handler onJ4Error and not call it onError? You are doing:

if (version_compare(JVERSION, '4', '>=') && Koowa::isDebug()) { $subject->addListener('onError', array($this, 'onJ4Error'), Joomla\Event\Priority::ABOVE_NORMAL); }

If Joomla calls onError on system plugins we can just intercept it, implement this check there and then proxy it?

This comment has been minimized.

Copy link
@amazeika

amazeika Dec 10, 2021

Author Member

@johanjanssens This got reversed yesterday.

This comment has been minimized.

Copy link
@amazeika

amazeika Dec 10, 2021

Author Member

@johanjanssens We still had problems with error handling, it took two iterations to get it right :), last commits fixed it for good

This comment has been minimized.

Copy link
@johanjanssens

johanjanssens Dec 10, 2021

Member

Great! Will re-review when you are done. What did you change, got a link to that?

This comment has been minimized.

Copy link
@amazeika

amazeika Dec 10, 2021

Author Member

@johanjanssens you already did, it's in this commit => 611f45b#commitcomment-61699709 (at the very end). It gets back to how it was before, e.g. onError instead as you say.

{
$exception = $event->getError();

if ($exception instanceof \Throwable) {
$this->_proxyEvent('onException', ['exception' => $exception]);
}
Expand Down

0 comments on commit cb43da9

Please sign in to comment.