Moved exception handler to a big try catch

This commit is contained in:
Shoghi Cervantes 2015-09-11 09:09:45 +02:00
parent e137ac4c56
commit 922e9d93d5

View File

@ -1445,9 +1445,7 @@ class Server{
public static function microSleep(int $microseconds){ public static function microSleep(int $microseconds){
Server::$sleeper->synchronized(function(int $ms){ Server::$sleeper->synchronized(function(int $ms){
var_dump("Sleeping $ms");
Server::$sleeper->wait($ms); Server::$sleeper->wait($ms);
var_dump("Finished sleep $ms");
}, $microseconds); }, $microseconds);
} }
@ -1461,9 +1459,11 @@ class Server{
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){ public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
self::$instance = $this; self::$instance = $this;
self::$sleeper = \ThreadedFactory::create(); self::$sleeper = \ThreadedFactory::create();
$this->autoloader = $autoloader; $this->autoloader = $autoloader;
$this->logger = $logger; $this->logger = $logger;
try{
$this->filePath = $filePath; $this->filePath = $filePath;
if(!file_exists($dataPath . "worlds/")){ if(!file_exists($dataPath . "worlds/")){
mkdir($dataPath . "worlds/", 0777); mkdir($dataPath . "worlds/", 0777);
@ -1635,7 +1635,6 @@ class Server{
$this->pluginManager->registerInterface(PharPluginLoader::class); $this->pluginManager->registerInterface(PharPluginLoader::class);
$this->pluginManager->registerInterface(ScriptPluginLoader::class); $this->pluginManager->registerInterface(ScriptPluginLoader::class);
set_exception_handler([$this, "exceptionHandler"]);
register_shutdown_function([$this, "crashDump"]); register_shutdown_function([$this, "crashDump"]);
$this->queryRegenerateTask = new QueryRegenerateEvent($this, 5); $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
@ -1710,6 +1709,9 @@ class Server{
$this->enablePlugins(PluginLoadOrder::POSTWORLD); $this->enablePlugins(PluginLoadOrder::POSTWORLD);
$this->start(); $this->start();
}catch(\Throwable $e){
$this->exceptionHandler($e);
}
} }
/** /**