mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
Replace InvalidStateException usages with InvalidArgument or LogicException
This commit is contained in:
@ -92,7 +92,7 @@ class AsyncWorker extends Worker{
|
||||
*/
|
||||
public function saveToThreadStore(string $identifier, $value) : void{
|
||||
if(\Thread::getCurrentThread() !== $this){
|
||||
throw new \InvalidStateException("Thread-local data can only be stored in the thread context");
|
||||
throw new \LogicException("Thread-local data can only be stored in the thread context");
|
||||
}
|
||||
self::$store[$identifier] = $value;
|
||||
}
|
||||
@ -109,7 +109,7 @@ class AsyncWorker extends Worker{
|
||||
*/
|
||||
public function getFromThreadStore(string $identifier){
|
||||
if(\Thread::getCurrentThread() !== $this){
|
||||
throw new \InvalidStateException("Thread-local data can only be fetched in the thread context");
|
||||
throw new \LogicException("Thread-local data can only be fetched in the thread context");
|
||||
}
|
||||
return self::$store[$identifier] ?? null;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class AsyncWorker extends Worker{
|
||||
*/
|
||||
public function removeFromThreadStore(string $identifier) : void{
|
||||
if(\Thread::getCurrentThread() !== $this){
|
||||
throw new \InvalidStateException("Thread-local data can only be removed in the thread context");
|
||||
throw new \LogicException("Thread-local data can only be removed in the thread context");
|
||||
}
|
||||
unset(self::$store[$identifier]);
|
||||
}
|
||||
|
@ -88,12 +88,9 @@ class TaskScheduler{
|
||||
return $this->tasks->contains($task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
private function addTask(Task $task, int $delay, int $period) : TaskHandler{
|
||||
if(!$this->enabled){
|
||||
throw new \InvalidStateException("Tried to schedule task to disabled scheduler");
|
||||
throw new \LogicException("Tried to schedule task to disabled scheduler");
|
||||
}
|
||||
|
||||
if($delay <= 0){
|
||||
|
Reference in New Issue
Block a user