mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Catch uncatched thrown Exceptions to get useful backtraces
This commit is contained in:
@ -1053,7 +1053,7 @@ class Server{
|
||||
}
|
||||
|
||||
if(($provider = LevelProviderManager::getProviderByName($this->getProperty("level-settings.default-format", "mcregion"))) === null){
|
||||
$provider = "pocketmine\\level\\format\\mcregion\\McRegion";
|
||||
$provider = LevelProviderManager::getProviderByName("mcregion");
|
||||
}
|
||||
|
||||
$path = $this->getDataPath() . "worlds/" . $name . "/";
|
||||
@ -1450,7 +1450,7 @@ class Server{
|
||||
$this->setConfigInt("difficulty", 3);
|
||||
}
|
||||
|
||||
define("pocketmine\\DEBUG", $this->getProperty("debug.level", 1));
|
||||
define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
|
||||
if($this->logger instanceof MainLogger){
|
||||
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
||||
}
|
||||
@ -1490,8 +1490,9 @@ class Server{
|
||||
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
|
||||
$this->pluginManager->registerInterface("pocketmine\\plugin\\PharPluginLoader");
|
||||
|
||||
register_shutdown_function(array($this, "crashDump"));
|
||||
register_shutdown_function(array($this, "forceShutdown"));
|
||||
set_exception_handler([$this, "exceptionHandler"]);
|
||||
register_shutdown_function([$this, "crashDump"]);
|
||||
register_shutdown_function([$this, "forceShutdown"]);
|
||||
|
||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||
|
||||
@ -1805,6 +1806,20 @@ class Server{
|
||||
}
|
||||
}
|
||||
|
||||
public function exceptionHandler(\Exception $e){
|
||||
if($e === null){
|
||||
return;
|
||||
}
|
||||
|
||||
error_handler(E_ERROR, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTrace());
|
||||
global $lastExceptionError, $lastError;
|
||||
$lastExceptionError = $lastError;
|
||||
$this->crashDump();
|
||||
$this->forceShutdown();
|
||||
kill(getmypid());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
public function crashDump(){
|
||||
if($this->isRunning === false){
|
||||
return;
|
||||
|
Reference in New Issue
Block a user