wsp-10323 Step 9

This commit is contained in:
me 2015-03-23 19:13:25 +04:00
parent 4bd3dbc9fe
commit 1b967de004
9 changed files with 298 additions and 20 deletions

View file

@ -66,12 +66,13 @@ namespace WebsitePanel.Providers.Virtualization
public Collection<PSObject> Execute(Command cmd, bool addComputerNameParameter)
{
object[] errors;
return Execute(cmd, addComputerNameParameter, out errors);
return Execute(cmd, addComputerNameParameter, false);
}
public Collection<PSObject> Execute(Command cmd, bool addComputerNameParameter, out object[] errors)
public Collection<PSObject> Execute(Command cmd, bool addComputerNameParameter, bool withExceptions)
{
HostedSolutionLog.LogStart("Execute");
List<object> errorList = new List<object>();
HostedSolutionLog.DebugCommand(cmd);
@ -110,14 +111,17 @@ namespace WebsitePanel.Providers.Virtualization
}
}
pipeLine = null;
errors = errorList.ToArray();
if (withExceptions)
ExceptionIfErrors(errorList);
HostedSolutionLog.LogEnd("Execute");
return results;
}
public static void ExceptionIfErrors(object[] errors)
private static void ExceptionIfErrors(List<object> errors)
{
if (errors != null && errors.Length > 0)
if (errors != null && errors.Count > 0)
throw new Exception("Invoke error: " + string.Join("; ", errors.Select(e => e.ToString())));
}
}