Refactor handleError function to handle ModelNotFoundException

This commit is contained in:
Andras Bacsai
2024-10-17 21:48:47 +02:00
parent df4e4c2b4e
commit bfa9a8776e

View File

@@ -142,6 +142,10 @@ function handleError(?Throwable $error = null, ?Livewire\Component $livewire = n
return 'Duplicate entry found. Please use a different name.'; return 'Duplicate entry found. Please use a different name.';
} }
if ($error instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
abort(404);
}
if ($error instanceof Throwable) { if ($error instanceof Throwable) {
$message = $error->getMessage(); $message = $error->getMessage();
} else { } else {
@@ -3983,13 +3987,14 @@ function instanceSettings()
return InstanceSettings::get(); return InstanceSettings::get();
} }
function loadConfigFromGit(string $repository, string $branch, string $base_directory, int $server_id, int $team_id) { function loadConfigFromGit(string $repository, string $branch, string $base_directory, int $server_id, int $team_id)
{
$server = Server::find($server_id)->where('team_id', $team_id)->first(); $server = Server::find($server_id)->where('team_id', $team_id)->first();
if (! $server) { if (! $server) {
return; return;
} }
$uuid = new Cuid2(); $uuid = new Cuid2;
$cloneCommand = "git clone --no-checkout -b $branch $repository ."; $cloneCommand = "git clone --no-checkout -b $branch $repository .";
$workdir = rtrim($base_directory, '/'); $workdir = rtrim($base_directory, '/');
$fileList = collect([".$workdir/coolify.json"]); $fileList = collect([".$workdir/coolify.json"]);