@@ -121,25 +121,18 @@ public function postNewServer(Request $request)
121121 {
122122
123123 try {
124-
125124 $ server = new ServerRepository ;
126125 $ response = $ server ->create ($ request ->all ());
127-
128126 return redirect ()->route ('admin.servers.view ' , [ 'id ' => $ response ]);
129-
130- } catch (\Exception $ e ) {
131-
132- if ($ e instanceof \Pterodactyl \Exceptions \DisplayValidationException) {
133- return redirect ()->route ('admin.servers.new ' )->withErrors (json_decode ($ e ->getMessage ()))->withInput ();
134- } else if ($ e instanceof \Pterodactyl \Exceptions \DisplayException) {
135- Alert::danger ($ e ->getMessage ())->flash ();
136- } else {
137- Debugbar::addException ($ e );
138- Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
139- }
140-
127+ } catch (DisplayValidationException $ ex ) {
128+ return redirect ()->route ('admin.servers.new ' )->withErrors (json_decode ($ ex ->getMessage ()))->withInput ();
129+ } catch (DisplayException $ ex ) {
130+ Alert::danger ($ ex ->getMessage ())->flash ();
131+ return redirect ()->route ('admin.servers.new ' )->withInput ();
132+ } catch (\Exception $ ex ) {
133+ Log::error ($ ex );
134+ Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
141135 return redirect ()->route ('admin.servers.new ' )->withInput ();
142-
143136 }
144137
145138 }
@@ -259,27 +252,26 @@ public function postUpdateServerDetails(Request $request, $id)
259252 'id ' => $ id ,
260253 'tab ' => 'tab_details '
261254 ]);
262-
263- } catch (\Exception $ e ) {
264-
265- if ($ e instanceof \Pterodactyl \Exceptions \DisplayValidationException) {
266- return redirect ()->route ('admin.servers.view ' , [
267- 'id ' => $ id ,
268- 'tab ' => 'tab_details '
269- ])->withErrors (json_decode ($ e ->getMessage ()))->withInput ();
270- } else if ($ e instanceof \Pterodactyl \Exceptions \DisplayException) {
271- Alert::danger ($ e ->getMessage ())->flash ();
272- } else {
273- Log::error ($ e );
274- Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
275- }
276-
255+ } catch (DisplayValidationException $ ex ) {
256+ return redirect ()->route ('admin.servers.view ' , [
257+ 'id ' => $ id ,
258+ 'tab ' => 'tab_details '
259+ ])->withErrors (json_decode ($ ex ->getMessage ()))->withInput ();
260+ } catch (DisplayException $ ex ) {
261+ Alert::danger ($ ex ->getMessage ())->flash ();
262+ return redirect ()->route ('admin.servers.view ' , [
263+ 'id ' => $ id ,
264+ 'tab ' => 'tab_details '
265+ ])->withInput ();
266+ } catch (\Exception $ ex ) {
267+ Log::error ($ ex );
268+ Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
277269 return redirect ()->route ('admin.servers.view ' , [
278270 'id ' => $ id ,
279271 'tab ' => 'tab_details '
280272 ])->withInput ();
281-
282273 }
274+
283275 }
284276
285277 public function postUpdateServerToggleBuild (Request $ request , $ id ) {
@@ -321,20 +313,22 @@ public function postUpdateServerUpdateBuild(Request $request, $id)
321313 'cpu ' => $ request ->input ('cpu ' ),
322314 ]);
323315 Alert::success ('Server details were successfully updated. ' )->flash ();
324- } catch (\Exception $ e ) {
325-
326- if ($ e instanceof \Pterodactyl \Exceptions \DisplayValidationException) {
327- return redirect ()->route ('admin.servers.view ' , [
328- 'id ' => $ id ,
329- 'tab ' => 'tab_build '
330- ])->withErrors (json_decode ($ e ->getMessage ()))->withInput ();
331- } else if ($ e instanceof \Pterodactyl \Exceptions \DisplayException) {
332- Alert::danger ($ e ->getMessage ())->flash ();
333- } else {
334- Log::error ($ e );
335- Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
336- }
316+ } catch (DisplayValidationException $ ex ) {
317+ return redirect ()->route ('admin.servers.view ' , [
318+ 'id ' => $ id ,
319+ 'tab ' => 'tab_build '
320+ ])->withErrors (json_decode ($ ex ->getMessage ()))->withInput ();
321+ } catch (DisplayException $ ex ) {
322+ Alert::danger ($ ex ->getMessage ())->flash ();
323+ return redirect ()->route ('admin.servers.view ' , [
324+ 'id ' => $ id ,
325+ 'tab ' => 'tab_build '
326+ ]);
327+ } catch (\Exception $ ex ) {
328+ Log::error ($ ex );
329+ Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
337330 }
331+
338332 return redirect ()->route ('admin.servers.view ' , [
339333 'id ' => $ id ,
340334 'tab ' => 'tab_build '
@@ -348,16 +342,17 @@ public function deleteServer(Request $request, $id, $force = null)
348342 $ server ->deleteServer ($ id , $ force );
349343 Alert::success ('Server was successfully deleted from the panel and the daemon. ' )->flash ();
350344 return redirect ()->route ('admin.servers ' );
351- } catch (\Pterodactyl \Exceptions \DisplayException $ e ) {
352- Alert::danger ($ e ->getMessage ())->flash ();
353- } catch (\Exception $ e ) {
354- Log::error ($ e );
355- Alert::danger ('An unhandled exception occured while attemping to add this server. Please try again. ' )->flash ();
345+ } catch (DisplayException $ ex ) {
346+ Alert::danger ($ ex ->getMessage ())->flash ();
347+ } catch (\Exception $ ex ) {
348+ Log::error ($ ex );
349+ Alert::danger ('An unhandled exception occured while attemping to delete this server. Please try again. ' )->flash ();
350+ } finally {
351+ return redirect ()->route ('admin.servers.view ' , [
352+ 'id ' => $ id ,
353+ 'tab ' => 'tab_delete '
354+ ]);
356355 }
357- return redirect ()->route ('admin.servers.view ' , [
358- 'id ' => $ id ,
359- 'tab ' => 'tab_delete '
360- ]);
361356 }
362357
363358 public function postToggleInstall (Request $ request , $ id )
@@ -366,7 +361,7 @@ public function postToggleInstall(Request $request, $id)
366361 $ server = new ServerRepository ;
367362 $ server ->toggleInstall ($ id );
368363 Alert::success ('Server status was successfully toggled. ' )->flash ();
369- } catch (\ Pterodactyl \ Exceptions \ DisplayException $ ex ) {
364+ } catch (DisplayException $ ex ) {
370365 Alert::danger ($ ex ->getMessage ())->flash ();
371366 } catch (\Exception $ ex ) {
372367 Log::error ($ ex );
@@ -408,7 +403,7 @@ public function postDatabase(Request $request, $id)
408403 '_token '
409404 ]));
410405 Alert::success ('Added new database to this server. ' )->flash ();
411- } catch (\ Pterodactyl \ Exceptions \ DisplayValidationException $ ex ) {
406+ } catch (DisplayValidationException $ ex ) {
412407 return redirect ()->route ('admin.servers.view ' , [
413408 'id ' => $ id ,
414409 'tab ' => 'tab_database '
@@ -430,7 +425,7 @@ public function postSuspendServer(Request $request, $id)
430425 $ repo = new ServerRepository ;
431426 $ repo ->suspend ($ id );
432427 Alert::success ('Server has been suspended on the system. All running processes have been stopped and will not be startable until it is un-suspended. ' );
433- } catch (\ Pterodactyl \ Exceptions \ DisplayException $ e ) {
428+ } catch (DisplayException $ e ) {
434429 Alert::danger ($ e ->getMessage ())->flash ();
435430 } catch (\Exception $ e ) {
436431 Log::error ($ e );
@@ -449,7 +444,7 @@ public function postUnsuspendServer(Request $request, $id)
449444 $ repo = new ServerRepository ;
450445 $ repo ->unsuspend ($ id );
451446 Alert::success ('Server has been unsuspended on the system. Access has been re-enabled. ' );
452- } catch (\ Pterodactyl \ Exceptions \ DisplayException $ e ) {
447+ } catch (DisplayException $ e ) {
453448 Alert::danger ($ e ->getMessage ())->flash ();
454449 } catch (\Exception $ e ) {
455450 Log::error ($ e );
0 commit comments