Skip to content

Commit 3b741ae

Browse files
committed
Use Error.beforeRender and stop event propagation.
1 parent a0772d9 commit 3b741ae

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/Plugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function console(CommandCollection $commands): CommandCollection
9393
public function setDeprecationHandler($service)
9494
{
9595
if (!empty($service->getConfig('panels')['DebugKit.Deprecations'])) {
96-
EventManager::instance()->on('Error.handled', function (EventInterface $event, PhpError $error) {
96+
EventManager::instance()->on('Error.beforeRender', function (EventInterface $event, PhpError $error) {
9797
$code = $error->getCode();
9898
if ($code !== E_USER_DEPRECATED && $code !== E_DEPRECATED) {
9999
return;
@@ -115,6 +115,7 @@ public function setDeprecationHandler($service)
115115
'file' => $file,
116116
'line' => $line,
117117
]);
118+
$event->stopPropagation();
118119
});
119120
}
120121
}

tests/TestCase/PluginTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public function testSetDeprecationHandler()
4141
$panel = new DeprecationsPanel();
4242

4343
$error = new PhpError(E_USER_WARNING, 'ignored', __FILE__, __LINE__, []);
44-
$event = new Event('Error.handled', null, ['error' => $error]);
44+
$event = new Event('Error.beforeRender', null, ['error' => $error]);
4545
EventManager::instance()->dispatch($event);
4646

4747
// No file/line in message.
4848
$error = new PhpError(E_USER_DEPRECATED, 'going away', __FILE__, __LINE__, []);
49-
$event = new Event('Error.handled', null, ['error' => $error]);
49+
$event = new Event('Error.beforeRender', null, ['error' => $error]);
5050
EventManager::instance()->dispatch($event);
5151

5252
// Formatted like deprecationWarning()
@@ -57,7 +57,7 @@ public function testSetDeprecationHandler()
5757
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`.
5858
TEXT;
5959
$error = new PhpError(E_USER_DEPRECATED, $message, __FILE__, __LINE__, []);
60-
$event = new Event('Error.handled', null, ['error' => $error]);
60+
$event = new Event('Error.beforeRender', null, ['error' => $error]);
6161
EventManager::instance()->dispatch($event);
6262

6363
$panel->shutdown($event);

0 commit comments

Comments
 (0)