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
This commit is contained in:
Dane Everitt 2020-10-03 19:05:04 -07:00
parent d1c30607cf
commit 2d56cacbab
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -333,13 +333,18 @@ class ServersController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* *
* @throws \Illuminate\Validation\ValidationException * @throws \Illuminate\Validation\ValidationException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/ */
public function saveStartup(Request $request, Server $server) public function saveStartup(Request $request, Server $server)
{ {
$this->startupModificationService->setUserLevel(User::USER_LEVEL_ADMIN); try {
$this->startupModificationService->handle($server, $request->except('_token')); $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(); $this->alert->success(trans('admin/server.alerts.startup_changed'))->flash();
return redirect()->route('admin.servers.view.startup', $server->id); return redirect()->route('admin.servers.view.startup', $server->id);