Merge pull request #373 from NextTurn/catch

Don't print stack trace to console for user errors
pull/393/head
Oleg Nenashev 2020-01-31 22:53:38 +01:00 committed by GitHub
commit e06ae851f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);