Skip to content

Commit 4d31004

Browse files
committed
Suppress overly verbose error output to users
1 parent 445b2f2 commit 4d31004

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

app/Exceptions/DisplayException.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,26 @@
2323
*/
2424
namespace Pterodactyl\Exceptions;
2525

26+
use Log;
27+
2628
class DisplayException extends \Exception
2729
{
2830

31+
private $_logging = null;
32+
33+
public function __construct($message, $log = null)
34+
{
35+
$this->_logging = $log;
36+
if ($this->_logging !== null) {
37+
Log::error($log);
38+
}
39+
40+
parent::__construct($message);
41+
}
42+
43+
public function getLogging()
44+
{
45+
return $this->_logging;
46+
}
47+
2948
}

app/Http/Controllers/Admin/ServersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function postUpdateServerToggleBuild(Request $request, $id) {
286286
Alert::success('A rebuild has been queued successfully. It will run the next time this server is booted.')->flash();
287287
} catch (\GuzzleHttp\Exception\TransferException $ex) {
288288
Log::warning($ex);
289-
Alert::danger('An error occured while attempting to toggle a rebuild: ' . $ex->getMessage())->flash();
289+
Alert::danger('An error occured while attempting to toggle a rebuild.')->flash();
290290
}
291291

292292
return redirect()->route('admin.servers.view', [

app/Repositories/ServerRepository.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function create(array $data)
282282
return $server->id;
283283
} catch (\GuzzleHttp\Exception\TransferException $ex) {
284284
DB::rollBack();
285-
throw new DisplayException('An error occured while attempting to create the server: ' . $ex->getMessage());
285+
throw new DisplayException('An error occured while attempting to create the server.', $ex);
286286
} catch (\Exception $ex) {
287287
DB::rollBack();
288288
Log:error($ex);
@@ -530,7 +530,7 @@ public function changeBuild($id, array $data)
530530
return true;
531531
} catch (\GuzzleHttp\Exception\TransferException $ex) {
532532
DB::rollBack();
533-
throw new DisplayException('An error occured while attempting to update the configuration: ' . $ex->getMessage());
533+
throw new DisplayException('An error occured while attempting to update the configuration.', $ex);
534534
} catch (\Exception $ex) {
535535
DB::rollBack();
536536
throw $ex;
@@ -647,7 +647,7 @@ public function updateStartup($id, array $data, $admin = false)
647647
return true;
648648
} catch (\GuzzleHttp\Exception\TransferException $ex) {
649649
DB::rollBack();
650-
throw new DisplayException('An error occured while attempting to update the server configuration: ' . $ex->getMessage());
650+
throw new DisplayException('An error occured while attempting to update the server configuration.', $ex);
651651
} catch (\Exception $ex) {
652652
DB::rollBack();
653653
throw $ex;
@@ -697,8 +697,7 @@ public function deleteServer($id, $force)
697697
return true;
698698
} else {
699699
DB::rollBack();
700-
Log::error($ex);
701-
throw new DisplayException('An error occured while attempting to delete the server on the daemon: ' . $ex->getMessage());
700+
throw new DisplayException('An error occured while attempting to delete the server on the daemon.', $ex);
702701
}
703702
} catch (\Exception $ex) {
704703
DB::rollBack();
@@ -768,7 +767,7 @@ public function updateSFTPPassword($id, $password)
768767
]);
769768
return true;
770769
} catch (\GuzzleHttp\Exception\TransferException $ex) {
771-
throw new DisplayException('There was an error while attmping to contact the remote service to change the password.');
770+
throw new DisplayException('There was an error while attmping to contact the remote service to change the password.', $ex);
772771
} catch (\Exception $ex) {
773772
throw $ex;
774773
}

app/Repositories/SubuserRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function create($sid, array $data)
195195
return $subuser->id;
196196
} catch (\GuzzleHttp\Exception\TransferException $ex) {
197197
DB::rollBack();
198-
throw new DisplayException('There was an error attempting to connect to the daemon to add this user.');
198+
throw new DisplayException('There was an error attempting to connect to the daemon to add this user.', $ex);
199199
} catch (\Exception $ex) {
200200
DB::rollBack();
201201
throw $ex;
@@ -241,7 +241,7 @@ public function delete($id)
241241
return true;
242242
} catch (\GuzzleHttp\Exception\TransferException $ex) {
243243
DB::rollBack();
244-
throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.');
244+
throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.', $ex);
245245
} catch (\Exception $ex) {
246246
DB::rollBack();
247247
throw $ex;
@@ -316,7 +316,7 @@ public function update($id, array $data)
316316
return true;
317317
} catch (\GuzzleHttp\Exception\TransferException $ex) {
318318
DB::rollBack();
319-
throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.');
319+
throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.', $ex);
320320
} catch (\Exception $ex) {
321321
DB::rollBack();
322322
throw $ex;

0 commit comments

Comments
 (0)