Skip to content
This repository has been archived by the owner on Jun 17, 2019. It is now read-only.

Commit

Permalink
Improved error messages for unsupported RM versions that are newer th…
Browse files Browse the repository at this point in the history
…an the tool, added RM 2015.1 support
  • Loading branch information
DanielMannInCycle committed Dec 7, 2015
1 parent 58872b3 commit 4a67060
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/RMWorkflowMigrator.CmdLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@ namespace Microsoft.ALMRangers.RMWorkflowMigrator.CmdLine
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using CommandLine;

using DataAccess.Model;
using DataAccess.Repository;
using Generator.PowerShell;
using Generator.PowerShell.Model;
using Parser;
using Parser.Model;

using ApplicationInsights;
using ApplicationInsights.Extensibility;





public static class Program
{
private const string ApplicationInsightsKey = "8493dd94-b866-47d8-ab6d-f61556fcc31a";
Expand All @@ -45,7 +40,8 @@ public static class Program

// Everything above this point is untested. U3 may work. Earlier is unlikely.
{ "12.0.31101.0", true },
{ "14.0.23102.0", true }
{ "14.0.23102.0", true },
{ "14.0.24712.0", true }
};

private static readonly Dictionary<string, string> VersionMapping = new Dictionary<string, string>
Expand All @@ -55,7 +51,8 @@ public static class Program
{ "12.0.30501.0", "2013 Update 2" },
{ "12.0.30723.0", "2013 Update 3" },
{ "12.0.31101.0", "2013 Update 4" },
{ "14.0.23102.0", "2015 RTM" }
{ "14.0.23102.0", "2015 RTM" },
{ "14.0.24712.0", "2015 Update 1" }
};

private static Options options;
Expand Down Expand Up @@ -131,20 +128,31 @@ private static async Task<RMVersion> RetrieveRmVersion()
{
var versionRepo = new RMVersionRepository(options.ConnectionString);
var version = await versionRepo.GetRMVersion();
if (!VersionMapping.ContainsKey(version))
{
throw new UnsupportedReleaseManagementVersionException(GenerateUnsupportedVersionExceptionMessage(version));
}
PrintOnlyIfVerbose($"Release Management version detected: {version} ({VersionMapping[version]})");

if (SupportedVersions[version])
{
return version.StartsWith("14.") ? RMVersion.Rm2015 : RMVersion.Rm2013;
}

throw new UnsupportedReleaseManagementVersionException(GenerateUnsupportedVersionExceptionMessage(version));
}

private static string GenerateUnsupportedVersionExceptionMessage(string version)
{
var exceptionMessage = new StringBuilder();
exceptionMessage.AppendLine($"Version {version} ({VersionMapping[version]}) is unsupported.");
var supportedVersions = SupportedVersions.Where(srv => srv.Value).Select(srv => VersionMapping[srv.Key]);
exceptionMessage.AppendLine(
!VersionMapping.ContainsKey(version)
? $"Version {version} is unsupported."
: $"Version {version} ({VersionMapping[version]}) is unsupported.");
var supportedVersions = SupportedVersions.Where(srv => srv.Value).Select(srv => $"{VersionMapping[srv.Key]} ({srv.Key})");
exceptionMessage.AppendLine("Supported versions:");
exceptionMessage.AppendLine(string.Join($",{Environment.NewLine}", supportedVersions));

throw new UnsupportedReleaseManagementVersionException(exceptionMessage.ToString());
return exceptionMessage.ToString();
}

private static async Task RunGeneratorAsync()
Expand Down

0 comments on commit 4a67060

Please sign in to comment.