Skip to content

Commit

Permalink
#10514 Improved messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jan 16, 2025
1 parent 5fbb8ba commit 252f21c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions classes/plugins/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public static function run(string $hookName, array $args = []): bool
}
} catch (Throwable $e) {
foreach ($e->getTrace() as $stackFrame) {
if (is_subclass_of($class = $stackFrame['class'] ?? null, Plugin::class)) {
error_log("Hook handler failure detected at {$class}\n{$e}");
if (is_subclass_of($pluginClass = $stackFrame['class'] ?? null, Plugin::class)) {
error_log("Plugin {$pluginClass} failed to handle the hook {$hookName}\n{$e}");
continue 2;
}
}
Expand Down
13 changes: 8 additions & 5 deletions classes/plugins/PluginRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public static function register(string $category, Plugin $plugin, string $path,
try {
$pluginName = $plugin->getName();
} catch (Throwable $e) {
error_log("Plugin getName() call has failed\n{$e}");
$pluginClass = $plugin::class;
error_log("Plugin {$pluginClass} getName() call has failed\n{$e}");
return false;
}
$plugins = & static::getPlugins();
Expand All @@ -84,7 +85,8 @@ public static function register(string $category, Plugin $plugin, string $path,
return false;
}
} catch (Throwable $e) {
error_log("Plugin failed to be registered\n{$e}");
$pluginClass = $plugin::class;
error_log("Plugin {$pluginClass} failed to be registered\n{$e}");
return false;
}

Expand Down Expand Up @@ -208,7 +210,7 @@ private static function instantiatePlugin(string $category, string $pluginName,
? new $pluginClassName()
: static::deprecatedInstantiatePlugin($category, $pluginName);
} catch (Throwable $e) {
error_log("Plugin instantiation has failed\n{$e}");
error_log("Instantiation of the plugin {$category}/{$pluginName} has failed\n{$e}");
return null;
}

Expand All @@ -220,7 +222,7 @@ private static function instantiatePlugin(string $category, string $pluginName,
}
if ($plugin !== null && !($plugin instanceof $classToCheck)) {
$type = $isObject ? $plugin::class : gettype($plugin);
error_log(new Exception("Plugin {$pluginName} expected to inherit from {$classToCheck}, actual type {$type}"));
error_log(new Exception("Plugin {$category}/{$pluginName} expected to inherit from {$classToCheck}, actual type {$type}"));
return null;
}
return $plugin;
Expand Down Expand Up @@ -297,7 +299,8 @@ private static function getPluginSeq(Plugin $plugin): int
try {
return $plugin->getSeq();
} catch (Throwable $e) {
error_log("Plugin getSeq() call has failed\n{$e}");
$pluginClass = $plugin::class;
error_log("Plugin {$pluginClass} getSeq() call has failed\n{$e}");
return 0;
}
}
Expand Down

0 comments on commit 252f21c

Please sign in to comment.