Skip to content

Commit

Permalink
Add error suppression to make listing work better.
Browse files Browse the repository at this point in the history
  • Loading branch information
miniksa committed Apr 25, 2018
1 parent 550e197 commit d6e77ed
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tools/ColorTool/ColorTool/ISchemeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ interface ISchemeParser
{
string Name { get; }

uint[] ParseScheme(string schemeName);
uint[] ParseScheme(string schemeName, bool reportErrors = true);
}
}
12 changes: 9 additions & 3 deletions tools/ColorTool/ColorTool/IniSchemeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static string FindIniScheme(string schemeName)
return null;
}

public uint[] ParseScheme(string schemeName)
public uint[] ParseScheme(string schemeName, bool reportErrors = true)
{
bool success = true;

Expand All @@ -127,7 +127,10 @@ public uint[] ParseScheme(string schemeName)
if (tableStrings[i].Length <= 0)
{
success = false;
Console.WriteLine(string.Format(Resources.IniParseError, filename, name, tableStrings[i]));
if (reportErrors)
{
Console.WriteLine(string.Format(Resources.IniParseError, filename, name, tableStrings[i]));
}
break;
}
}
Expand All @@ -144,7 +147,10 @@ public uint[] ParseScheme(string schemeName)
}
catch (Exception /*e*/)
{
Console.WriteLine(string.Format(Resources.IniLoadError, filename));
if (reportErrors)
{
Console.WriteLine(string.Format(Resources.IniLoadError, filename));
}

colorTable = null;
}
Expand Down
6 changes: 3 additions & 3 deletions tools/ColorTool/ColorTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static void PrintSchemes()
string fgText = " gYw ";
foreach (string schemeName in Directory.GetFiles("./schemes/").Select(Path.GetFileName))
{
uint[] colorTable = GetSchemeUints(schemeName);
uint[] colorTable = GetSchemeUints(schemeName, false);
if (colorTable != null)
{
string colors = string.Empty;
Expand Down Expand Up @@ -389,11 +389,11 @@ private static IEnumerable<ISchemeParser> GetParsers()
.Select(t => (ISchemeParser)Activator.CreateInstance(t));
}

private static uint[] GetSchemeUints(string schemeName)
private static uint[] GetSchemeUints(string schemeName, bool reportErrors = true)
{
foreach (var parser in GetParsers())
{
uint[] table = parser.ParseScheme(schemeName);
uint[] table = parser.ParseScheme(schemeName, reportErrors);
if (table != null)
{
return table;
Expand Down
7 changes: 7 additions & 0 deletions tools/ColorTool/ColorTool/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"ColorTool": {
"commandName": "Project"
}
}
}
7 changes: 5 additions & 2 deletions tools/ColorTool/ColorTool/XmlSchemeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static XmlDocument loadXmlScheme(string schemeName)
}


public uint[] ParseScheme(string schemeName)
public uint[] ParseScheme(string schemeName, bool reportErrors = true)
{
XmlDocument xmlDoc = loadXmlScheme(schemeName); // Create an XML document object
if (xmlDoc == null) return null;
Expand Down Expand Up @@ -167,7 +167,10 @@ public uint[] ParseScheme(string schemeName)
}
if (colorsFound < COLOR_TABLE_SIZE)
{
Console.WriteLine(Resources.InvalidNumberOfColors);
if (reportErrors)
{
Console.WriteLine(Resources.InvalidNumberOfColors);
}
success = false;
}
if (!success)
Expand Down

0 comments on commit d6e77ed

Please sign in to comment.