Don't print stack trace to console for invalid config files

pull/373/head
NextTurn 2019-02-19 00:00:00 +08:00
parent 48d4722b58
commit b3d4b466aa
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
2 changed files with 15 additions and 1 deletions

View File

@ -455,6 +455,13 @@ namespace winsw
Log.Debug("Completed. Exit code is 0");
return 0;
}
catch (InvalidDataException e)
{
string message = "The configuration file cound not be loaded. " + e.Message;
Log.Fatal(message, e);
Console.Error.WriteLine(message);
return -1;
}
catch (WmiException e)
{
Log.Fatal("WMI Operation failure: " + e.ErrorCode, e);

View File

@ -63,7 +63,14 @@ namespace winsw
BaseName = baseName;
BasePath = Path.Combine(d.FullName, BaseName);
dom.Load(BasePath + ".xml");
try
{
dom.Load(BasePath + ".xml");
}
catch (XmlException e)
{
throw new InvalidDataException(e.Message, e);
}
// register the base directory as environment variable so that future expansions can refer to this.
Environment.SetEnvironmentVariable("BASE", d.FullName);