Files
pterodactyl-panel/app/Exceptions/Http/Server/ServerStateConflictException.php
T

35 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Exceptions\Http\Server;
use Pterodactyl\Models\Server;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
2026-10-05 18:10:18 -04:00
use Throwable;
class ServerStateConflictException extends ConflictHttpException
{
/**
* Exception thrown when the server is in an unsupported state for API access or
* certain operations within the codebase.
*/
2026-10-05 18:10:18 -04:00
public function __construct(Server $server, ?Throwable $previous = null)
{
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.unsupported_state');
if ($server->isSuspended()) {
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.suspended');
} elseif ($server->node->isUnderMaintenance()) {
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.node_maintenance');
2026-10-05 18:10:18 -04:00
} elseif (! $server->isInstalled()) {
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.not_installed');
} elseif ($server->status === Server::STATUS_RESTORING_BACKUP) {
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.restoring_backup');
2026-10-05 18:10:18 -04:00
} elseif (($server->transfer) !== null) {
2026-11-23 14:51:03 +00:00
$message = __('exceptions.server.transferring');
}
parent::__construct($message, $previous);
}
}