mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-01-04 14:50:59 +01:00
Intercept error in connecting to the GPM and tell "Cannot connect to the GPM" instead of "Internal Server Error"
This commit is contained in:
28
admin.php
28
admin.php
@@ -294,19 +294,23 @@ class AdminPlugin extends Plugin
|
||||
switch ($action) {
|
||||
case 'getUpdates':
|
||||
$resources_updates = $gpm->getUpdatable();
|
||||
$grav_updates = [
|
||||
"isUpdatable" => $gpm->grav->isUpdatable(),
|
||||
"assets" => $gpm->grav->getAssets(),
|
||||
"version" => GRAV_VERSION,
|
||||
"available" => $gpm->grav->getVersion(),
|
||||
"date" => $gpm->grav->getDate(),
|
||||
"isSymlink" => $gpm->grav->isSymlink()
|
||||
];
|
||||
if ($gpm->grav != null) {
|
||||
$grav_updates = [
|
||||
"isUpdatable" => $gpm->grav->isUpdatable(),
|
||||
"assets" => $gpm->grav->getAssets(),
|
||||
"version" => GRAV_VERSION,
|
||||
"available" => $gpm->grav->getVersion(),
|
||||
"date" => $gpm->grav->getDate(),
|
||||
"isSymlink" => $gpm->grav->isSymlink()
|
||||
];
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush]
|
||||
]);
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush]
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Cannot connect to the GPM"]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user