From 2d56cacbab9245e46434ac0ef1d02ef353499304 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Oct 2020 19:05:04 -0700 Subject: [PATCH] Don't trigger a 500 error with bad data; closes #2442 This whole chunk of code needs some cleanup but I'll defer that for the new admin area in the future --- app/Http/Controllers/Admin/ServersController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index 400218e07..3f050b847 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -333,13 +333,18 @@ class ServersController extends Controller * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function saveStartup(Request $request, Server $server) { - $this->startupModificationService->setUserLevel(User::USER_LEVEL_ADMIN); - $this->startupModificationService->handle($server, $request->except('_token')); + try { + $this->startupModificationService + ->setUserLevel(User::USER_LEVEL_ADMIN) + ->handle($server, $request->except('_token')); + } catch (DataValidationException $exception) { + throw new ValidationException($exception->validator); + } + $this->alert->success(trans('admin/server.alerts.startup_changed'))->flash(); return redirect()->route('admin.servers.view.startup', $server->id);