Struct CommandResult
- Namespace
- Signal.Application.Commands
- Assembly
- Signal.Application.dll
Outcome of a command invocation: exactly one of CommandSucceeded, CommandNotFound,
CommandPreconditionFailed, CommandBindingFailed or CommandFaulted.
Stored in Items under typeof(CommandResult).
public struct CommandResult : IUnion
- Implements
- Inherited Members
Remarks
Each case carries exactly the data that exists for it (e.g. only CommandFaulted has an exception, CommandNotFound has no command). Switch over the result to handle every outcome; the compiler warns when a case is missing:
var text = result switch
{
CommandSucceeded => null,
CommandNotFound notFound => $"Unknown command {notFound.Parsed.Name}",
CommandPreconditionFailed failed => failed.Reason,
CommandBindingFailed failed => failed.Error,
CommandFaulted faulted => "Something went wrong",
};
Properties
IsSuccess
Whether the command ran to completion.
public bool IsSuccess { get; }
Property Value
Parsed
The parsed invocation, available for every outcome.
public ParsedCommand Parsed { get; }
Property Value
Exceptions
- InvalidOperationException
The result is default (holds no value).