fix(core): improve server selection error handling in Docker component
This commit is contained in:
parent
aacfbe453b
commit
372b064dba
1 changed files with 10 additions and 2 deletions
|
|
@ -35,10 +35,18 @@ public function mount(?string $server_id = null)
|
||||||
$this->network = new Cuid2;
|
$this->network = new Cuid2;
|
||||||
$this->servers = Server::isUsable()->get();
|
$this->servers = Server::isUsable()->get();
|
||||||
if ($server_id) {
|
if ($server_id) {
|
||||||
$this->selectedServer = $this->servers->find($server_id) ?: $this->servers->first();
|
$foundServer = $this->servers->find($server_id) ?: $this->servers->first();
|
||||||
|
if (! $foundServer) {
|
||||||
|
throw new \Exception('Server not found.');
|
||||||
|
}
|
||||||
|
$this->selectedServer = $foundServer;
|
||||||
$this->serverId = $this->selectedServer->id;
|
$this->serverId = $this->selectedServer->id;
|
||||||
} else {
|
} else {
|
||||||
$this->selectedServer = $this->servers->first();
|
$foundServer = $this->servers->first();
|
||||||
|
if (! $foundServer) {
|
||||||
|
throw new \Exception('Server not found.');
|
||||||
|
}
|
||||||
|
$this->selectedServer = $foundServer;
|
||||||
$this->serverId = $this->selectedServer->id;
|
$this->serverId = $this->selectedServer->id;
|
||||||
}
|
}
|
||||||
$this->generateName();
|
$this->generateName();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue