Throw 504 where necessary

This commit is contained in:
Dane Everitt 2018-03-06 22:17:01 -06:00
parent d3f797bf2a
commit 4964d294f6
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 12 additions and 2 deletions

View file

@ -8,6 +8,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* Fixes a UI error when attempting to change the default Nest and Egg for an existing server. * Fixes a UI error when attempting to change the default Nest and Egg for an existing server.
* Correct permissions check in UI to allow subusers with permission to `view-allocations` the ability to actually see the sidebar link. * Correct permissions check in UI to allow subusers with permission to `view-allocations` the ability to actually see the sidebar link.
### Changed
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.
## v0.7.5 (Derelict Dermodactylus) ## v0.7.5 (Derelict Dermodactylus)
### Fixed ### Fixed
* Fixes application API keys being created as a client API key. * Fixes application API keys being created as a client API key.

View file

@ -4,6 +4,8 @@ namespace Pterodactyl\Http\Controllers\Base;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Models\User; use Pterodactyl\Models\User;
use Illuminate\Http\Response;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
@ -81,6 +83,8 @@ class IndexController extends Controller
try { try {
$response = $this->daemonRepository->setServer($server)->setToken($token)->details(); $response = $this->daemonRepository->setServer($server)->setToken($token)->details();
} catch (ConnectException $exception) {
throw new HttpException(Response::HTTP_GATEWAY_TIMEOUT, $exception->getMessage());
} catch (RequestException $exception) { } catch (RequestException $exception) {
throw new HttpException(500, $exception->getMessage()); throw new HttpException(500, $exception->getMessage());
} }

View file

@ -80,8 +80,11 @@
} }
} }
}).fail(function (jqXHR) { }).fail(function (jqXHR) {
console.error(jqXHR); if (jqXHR.status === 504) {
element.find('[data-action="status"]').html('<span class="label label-default">Error</span>'); element.find('[data-action="status"]').html('<span class="label label-default">Gateway Timeout</span>');
} else {
element.find('[data-action="status"]').html('<span class="label label-default">Error</span>');
}
}); });
}).promise().done(function () { }).promise().done(function () {
setTimeout(updateServerStatus, 10000); setTimeout(updateServerStatus, 10000);