Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
854 B

using StabilityMatrix.Core.Exceptions;
namespace StabilityMatrix.Core.Processes;
public readonly record struct ProcessResult
{
public required int ExitCode { get; init; }
public string? StandardOutput { get; init; }
public string? StandardError { get; init; }
public string? ProcessName { get; init; }
public TimeSpan Elapsed { get; init; }
public bool IsSuccessExitCode => ExitCode == 0;
public void EnsureSuccessExitCode()
{
if (!IsSuccessExitCode)
{
throw new ProcessException(this);
}
}
}
public static class ProcessResultTaskExtensions
{
public static async Task<ProcessResult> EnsureSuccessExitCode(this Task<ProcessResult> task)
{
var result = await task.ConfigureAwait(false);
result.EnsureSuccessExitCode();
return result;
}
}