Merge branch 'develop' into feature/api-v1
This commit is contained in:
commit
46d7ba7585
32 changed files with 247 additions and 201 deletions
|
@ -65,7 +65,7 @@ class DisplayException extends PterodactylException
|
|||
if ($request->expectsJson()) {
|
||||
return response()->json(Handler::convertToArray($this, [
|
||||
'detail' => $this->getMessage(),
|
||||
]), 500);
|
||||
]), method_exists($this, 'getStatusCode') ? $this->getStatusCode() : 500);
|
||||
}
|
||||
|
||||
app()->make(AlertsMessageBag::class)->danger($this->getMessage())->flash();
|
||||
|
|
|
@ -7,18 +7,38 @@ use Pterodactyl\Exceptions\DisplayException;
|
|||
|
||||
class DaemonConnectionException extends DisplayException
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode = 500;
|
||||
|
||||
/**
|
||||
* Throw a displayable exception caused by a daemon connection error.
|
||||
*
|
||||
* @param \GuzzleHttp\Exception\GuzzleException $previous
|
||||
* @param bool $useStatusCode
|
||||
*/
|
||||
public function __construct(GuzzleException $previous)
|
||||
public function __construct(GuzzleException $previous, bool $useStatusCode = false)
|
||||
{
|
||||
/** @var \GuzzleHttp\Psr7\Response|null $response */
|
||||
$response = method_exists($previous, 'getResponse') ? $previous->getResponse() : null;
|
||||
|
||||
if ($useStatusCode) {
|
||||
$this->statusCode = is_null($response) ? 500 : $response->getStatusCode();
|
||||
}
|
||||
|
||||
parent::__construct(trans('admin/server.exceptions.daemon_exception', [
|
||||
'code' => is_null($response) ? 'E_CONN_REFUSED' : $response->getStatusCode(),
|
||||
]), $previous, DisplayException::LEVEL_WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTTP status code for this exception.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue