Пример #1
0
        internal ExecutionFailedResult(Command command, CommandExecutionStep commandExecutionStep, Exception exception)
        {
            Command = command;
            CommandExecutionStep = commandExecutionStep;
            Exception            = exception;

            while (Exception is TargetInvocationException)
            {
                Exception = Exception.InnerException;
            }

            switch (CommandExecutionStep)
            {
            case CommandExecutionStep.Checks:
                Reason = $"An exception occurred while running checks for {Command}.";
                break;

            case CommandExecutionStep.ArgumentParsing:
                Reason = $"An exception occurred while parsing raw arguments for {Command}.";
                break;

            case CommandExecutionStep.TypeParsing:
                Reason = $"An exception occurred while type parsing arguments for {Command}.";
                break;

            case CommandExecutionStep.BeforeExecuted:
                Reason = $"An exception occurred while calling before executed for {Command}.";
                break;

            case CommandExecutionStep.Command:
                Reason = $"An exception occurred while executing {Command}.";
                break;
            }
        }
Пример #2
0
        internal ExecutionFailedResult(Command command, CommandExecutionStep commandExecutionStep, Exception exception)
        {
            Command = command;
            CommandExecutionStep = commandExecutionStep;
            Exception            = exception;

            while (Exception is TargetInvocationException)
            {
                Exception = Exception.InnerException;
            }

            _lazyReason = new Lazy <string>(() =>
            {
                switch (CommandExecutionStep)
                {
                case CommandExecutionStep.Checks:
                    return($"An exception occurred while running checks for {Command}.");

                case CommandExecutionStep.ArgumentParsing:
                    return($"An exception occurred while parsing raw arguments for {Command}.");

                case CommandExecutionStep.TypeParsing:
                    return($"An exception occurred while type parsing arguments for {Command}.");

                case CommandExecutionStep.BeforeExecuted:
                    return($"An exception occurred while calling before executed for {Command}.");

                case CommandExecutionStep.Command:
                    return($"An exception occurred while executing {Command}.");

                default:
                    throw new InvalidOperationException("Invalid command execution step.");
                }
            }, true);
        }
Пример #3
0
        internal ExecutionFailedResult(Command command, CommandExecutionStep commandExecutionStep, Exception exception)
        {
            Command = command;
            CommandExecutionStep = commandExecutionStep;
            Exception            = exception;

            _lazyReason = new Lazy <string>(
                () => CommandExecutionStep switch
            {
                CommandExecutionStep.Checks => $"An exception occurred while running checks for {Command}.",
                CommandExecutionStep.ArgumentParsing => $"An exception occurred while parsing raw arguments for {Command}.",
                CommandExecutionStep.TypeParsing => $"An exception occurred while type parsing arguments for {Command}.",
                CommandExecutionStep.BeforeExecuted => $"An exception occurred while calling before executed for {Command}.",
                CommandExecutionStep.Command => $"An exception occurred while executing {Command}.",
                CommandExecutionStep.CooldownBucketKeyGenerating => $"An exception occurred while generating the cooldown bucket key for {Command}.",
                _ => throw new InvalidOperationException("Invalid command execution step."),
            }, true);