Replace InvalidStateException usages with InvalidArgument or LogicException

This commit is contained in:
Dylan K. Taylor
2021-11-02 16:05:54 +00:00
parent 4eef458d29
commit e34364412b
15 changed files with 24 additions and 30 deletions

View File

@ -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]);
}

View File

@ -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){