Cleaner error messages

This commit is contained in:
Andy Miller
2020-09-03 22:28:47 -06:00
parent c7fe6be9de
commit d063ac669b

View File

@@ -1052,7 +1052,11 @@ class AdminController extends AdminBaseController
try { try {
$result = Gpm::install($package, ['theme' => $type === 'theme']); $result = Gpm::install($package, ['theme' => $type === 'theme']);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()]; $msg = $e->getMessage();
$msg = Utils::contains($msg, '401 Unauthorized') ? "ERROR: Authorization failed for this resource" : $msg;
$msg = Utils::contains($msg, '404 Not Found') ? "ERROR: Resource not found" : $msg;
$this->admin->json_response = ['status' => 'error', 'message' => $msg];
return false; return false;
} }