Suppress overly verbose error output to users

This commit is contained in:
Dane Everitt 2016-08-16 19:20:58 -04:00
parent 445b2f20eb
commit 4d31004cf4
4 changed files with 28 additions and 10 deletions

View file

@ -23,7 +23,26 @@
*/ */
namespace Pterodactyl\Exceptions; namespace Pterodactyl\Exceptions;
use Log;
class DisplayException extends \Exception class DisplayException extends \Exception
{ {
private $_logging = null;
public function __construct($message, $log = null)
{
$this->_logging = $log;
if ($this->_logging !== null) {
Log::error($log);
}
parent::__construct($message);
}
public function getLogging()
{
return $this->_logging;
}
} }

View file

@ -286,7 +286,7 @@ class ServersController extends Controller
Alert::success('A rebuild has been queued successfully. It will run the next time this server is booted.')->flash(); Alert::success('A rebuild has been queued successfully. It will run the next time this server is booted.')->flash();
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
Log::warning($ex); Log::warning($ex);
Alert::danger('An error occured while attempting to toggle a rebuild: ' . $ex->getMessage())->flash(); Alert::danger('An error occured while attempting to toggle a rebuild.')->flash();
} }
return redirect()->route('admin.servers.view', [ return redirect()->route('admin.servers.view', [

View file

@ -282,7 +282,7 @@ class ServerRepository
return $server->id; return $server->id;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('An error occured while attempting to create the server: ' . $ex->getMessage()); throw new DisplayException('An error occured while attempting to create the server.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
Log:error($ex); Log:error($ex);
@ -530,7 +530,7 @@ class ServerRepository
return true; return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('An error occured while attempting to update the configuration: ' . $ex->getMessage()); throw new DisplayException('An error occured while attempting to update the configuration.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
throw $ex; throw $ex;
@ -647,7 +647,7 @@ class ServerRepository
return true; return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('An error occured while attempting to update the server configuration: ' . $ex->getMessage()); throw new DisplayException('An error occured while attempting to update the server configuration.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
throw $ex; throw $ex;
@ -697,8 +697,7 @@ class ServerRepository
return true; return true;
} else { } else {
DB::rollBack(); DB::rollBack();
Log::error($ex); throw new DisplayException('An error occured while attempting to delete the server on the daemon.', $ex);
throw new DisplayException('An error occured while attempting to delete the server on the daemon: ' . $ex->getMessage());
} }
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
@ -768,7 +767,7 @@ class ServerRepository
]); ]);
return true; return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
throw new DisplayException('There was an error while attmping to contact the remote service to change the password.'); throw new DisplayException('There was an error while attmping to contact the remote service to change the password.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
throw $ex; throw $ex;
} }

View file

@ -195,7 +195,7 @@ class SubuserRepository
return $subuser->id; return $subuser->id;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('There was an error attempting to connect to the daemon to add this user.'); throw new DisplayException('There was an error attempting to connect to the daemon to add this user.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
throw $ex; throw $ex;
@ -241,7 +241,7 @@ class SubuserRepository
return true; return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.'); throw new DisplayException('There was an error attempting to connect to the daemon to delete this subuser.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
throw $ex; throw $ex;
@ -316,7 +316,7 @@ class SubuserRepository
return true; return true;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
DB::rollBack(); DB::rollBack();
throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.'); throw new DisplayException('There was an error attempting to connect to the daemon to update permissions.', $ex);
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();
throw $ex; throw $ex;