Skip to content

Commit

Permalink
Log when exit code is not ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmds committed Dec 11, 2020
1 parent 8a2b95b commit 56604be
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Tasks/Exec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,23 +336,23 @@ protected override bool HandleTaskExecutionErrors()
{
if (IgnoreExitCode)
{
// Dont log when EchoOff and IgnoreExitCode.
if (!EchoOff)
{
Log.LogMessageFromResources(MessageImportance.Normal, "Exec.CommandFailedNoErrorCode", Command, ExitCode);
}
return true;
}

if (!EchoOff)
// Don't emit expanded command when EchoOff is set.
string commandForLogging = EchoOff ? nameof(EchoOff) : Command;
if (ExitCode == NativeMethods.SE_ERR_ACCESSDENIED)
{
if (ExitCode == NativeMethods.SE_ERR_ACCESSDENIED)
{
Log.LogErrorWithCodeFromResources("Exec.CommandFailedAccessDenied", Command, ExitCode);
}
else
{
Log.LogErrorWithCodeFromResources("Exec.CommandFailed", Command, ExitCode);
}
Log.LogErrorWithCodeFromResources("Exec.CommandFailedAccessDenied", commandForLogging, ExitCode);
}
else
{
Log.LogErrorWithCodeFromResources("Exec.CommandFailed", commandForLogging, ExitCode);
}
return false;
}
Expand Down

0 comments on commit 56604be

Please sign in to comment.