Skip to content

Commit 2d56cac

Browse files
committed
Don't trigger a 500 error with bad data; closes pterodactyl#2442
This whole chunk of code needs some cleanup but I'll defer that for the new admin area in the future
1 parent d1c3060 commit 2d56cac

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/Http/Controllers/Admin/ServersController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,18 @@ public function delete(Request $request, Server $server)
333333
* @return \Illuminate\Http\RedirectResponse
334334
*
335335
* @throws \Illuminate\Validation\ValidationException
336-
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
337336
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
338337
*/
339338
public function saveStartup(Request $request, Server $server)
340339
{
341-
$this->startupModificationService->setUserLevel(User::USER_LEVEL_ADMIN);
342-
$this->startupModificationService->handle($server, $request->except('_token'));
340+
try {
341+
$this->startupModificationService
342+
->setUserLevel(User::USER_LEVEL_ADMIN)
343+
->handle($server, $request->except('_token'));
344+
} catch (DataValidationException $exception) {
345+
throw new ValidationException($exception->validator);
346+
}
347+
343348
$this->alert->success(trans('admin/server.alerts.startup_changed'))->flash();
344349

345350
return redirect()->route('admin.servers.view.startup', $server->id);

0 commit comments

Comments
 (0)