Skip to content

PluginErrorEvent 5.46.0 ​

class · pocketmine\event\plugin\PluginErrorEvent · source

Extends PluginEvent
Implements Cancellable

Called when code belonging to a plugin throws an exception or error that the plugin did not catch, and the server isolated it instead of crashing (see \pocketmine\plugin\PluginFaultHandler).

This is intended for monitoring and error-reporting plugins.

Cancelling the event suppresses the server's default error log for this failure. The failure still counts towards the plugin's error limit, so a plugin that keeps failing will be disabled regardless.

This event is never called for failures of handlers of this event itself, to avoid infinite recursion.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\plugin\Plugin $plugin, \Throwable $throwable, string $context, int $recentErrorCount, bool $pluginWillBeDisabled)

getContext() ​

php
public function getContext() : string

Returns a human-readable description of the entry point in which the failure occurred, e.g. "event handler Foo::onJoin(PlayerJoinEvent)" or "command /foo".

getRecentErrorCount() ​

php
public function getRecentErrorCount() : int

Returns the number of unhandled errors the plugin has had within the configured error window, including this one.

getThrowable() ​

php
public function getThrowable() : \Throwable

Returns the exception or error that was thrown by the plugin.

willPluginBeDisabled() ​

php
public function willPluginBeDisabled() : bool

Returns whether this failure made the plugin reach its error limit, which means it will be disabled right after this event.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.