Cleaner error messages

This commit is contained in:
Andy Miller
2020-09-03 22:31:19 -06:00
parent 4802b84b05
commit 4f9aca8f3c

View File

@@ -1100,7 +1100,11 @@ class AdminController extends AdminBaseController
try {
$result = Gpm::install($package, ['theme' => $type === 'theme']);
} 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;
}