Add option to throw exception in build tool process utility

This commit is contained in:
Wojciech Figat
2022-01-10 14:36:19 +01:00
parent 730933dd35
commit f3d05cd98e
7 changed files with 28 additions and 18 deletions

View File

@@ -285,6 +285,11 @@ namespace Flax.Build
/// </summary>
NoLoggingOfRunDuration = 1 << 5,
/// <summary>
/// Throws exception when app returns non-zero return code.
/// </summary>
ThrowExceptionOnError = 1 << 6,
/// <summary>
/// The default options.
/// </summary>
@@ -424,6 +429,11 @@ namespace Flax.Build
{
Log.Info(string.Format("Took {0}s to run {1}, ExitCode={2}", stopwatch.Elapsed.TotalSeconds, Path.GetFileName(app), result));
}
if (result != 0 && options.HasFlag(RunOptions.ThrowExceptionOnError))
{
var format = options.HasFlag(RunOptions.NoLoggingOfRunCommand) ? "App failed with exit code {2}." : "{0} {1} failed with exit code {2}";
throw new Exception(string.Format(format, app, commandLine, result));
}
}
return result;