using System.Diagnostics;
namespace Discord.Commands
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RuntimeResult : IResult
{
///
/// Initializes a new class with the type of error and reason.
///
/// The type of failure, or null if none.
/// The reason of failure.
protected RuntimeResult(CommandError? error, string reason)
{
Error = error;
Reason = reason;
}
///
public CommandError? Error { get; }
/// Describes the execution reason or result.
public string Reason { get; }
///
public bool IsSuccess => !Error.HasValue;
///
string IResult.ErrorReason => Reason;
public override string ToString() => Reason ?? (IsSuccess ? "Successful" : "Unsuccessful");
private string DebuggerDisplay => IsSuccess ? $"Success: {Reason ?? "No Reason"}" : $"{Error}: {Reason}";
}
}