Skip to content

Commit 1d4fb2a

Browse files
committed
More checks on AsyncTask IDs
1 parent 304307b commit 1d4fb2a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/AsyncTask.php

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Process\InvokedProcess;
99
use Illuminate\Support\Facades\Process;
1010
use Illuminate\Support\Str;
11+
use InvalidArgumentException;
1112
use Laravel\SerializableClosure\SerializableClosure;
1213
use LogicException;
1314
use loophp\phposinfo\OsInfo;
@@ -109,6 +110,9 @@ public function __construct(Closure|AsyncTaskInterface $theTask, string|null $ta
109110
$theTask = new SerializableClosure($theTask);
110111
}
111112
$this->theTask = $theTask;
113+
if ($taskID === "") {
114+
throw new InvalidArgumentException("AsyncTask ID cannot be empty.");
115+
}
112116
$this->taskID = $taskID;
113117
}
114118

src/AsyncTaskStatus.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Vectorial1024\LaravelProcessAsync;
66

7-
use RuntimeException;
7+
use InvalidArgumentException;
88

99
/**
1010
* Represents the status of an async task: "running" or "stopped".
@@ -28,7 +28,7 @@ public function __construct(
2828
) {
2929
if ($taskID === "") {
3030
// why no blank IDs? because this will produce blank output via base64 encode.
31-
throw new RuntimeException("AsyncTask IDs cannot be blank");
31+
throw new InvalidArgumentException("AsyncTask IDs cannot be blank");
3232
}
3333
}
3434

0 commit comments

Comments
 (0)