report package installation errors, simplify code
[teamcity/dotNetPackagesSupport.git] / nuget-server / src / jetbrains / buildServer / nuget / server / toolRegistry / tab / InstallToolController.java
index a033e1adeb2d8367e7c28eef00ac85e57f047ee3..2ed991255b4057eed2aa364d482ef7d0a42adb67 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.controllers.*;\r
 import jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool;\r
 import jetbrains.buildServer.nuget.server.toolRegistry.NuGetToolManager;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.ToolException;\r
 import jetbrains.buildServer.nuget.server.toolRegistry.ToolsPolicy;\r
 import jetbrains.buildServer.serverSide.auth.AccessDeniedException;\r
 import jetbrains.buildServer.serverSide.auth.AuthorityHolder;\r
@@ -105,13 +106,19 @@ public class InstallToolController extends BaseFormXmlController {
     }\r
 \r
     final String whatToDo = request.getParameter("whatToDo");\r
-    if ("install".equals(whatToDo)) {\r
-      myToolsManager.installTool(toolId);\r
-      return;\r
-    }\r
+    try {\r
+      if ("install".equals(whatToDo)) {\r
+        myToolsManager.installTool(toolId);\r
+        return;\r
+      }\r
 \r
-    if ("remove".equals(whatToDo)) {\r
-      myToolsManager.removeTool(toolId);\r
+      if ("remove".equals(whatToDo)) {\r
+        myToolsManager.removeTool(toolId);\r
+      }\r
+    } catch (ToolException e) {\r
+      ActionErrors ae = new ActionErrors();\r
+      ae.addError("toolId", "Failed to install package: " + e.getMessage());\r
+      ae.serialize(xmlResponse);\r
     }\r
   }\r
 }\r