Example #1
0
        /// <summary>
        /// Checks if input is compatible and address accordingly (Exception, Empty or Fail)
        /// </summary>
        /// <returns>False if stack in fail state and needs to end, true otherwise</returns>
        public bool AssertCurrentBlockInput()
        {
            if (CurrentBlockSpec.InputType != null)
            {
                try
                {
                    NextInput = NextInput.ConvertTo(CurrentBlockSpec.InputType);
                }
                catch (Exception e)
                {
                    if (options.IncompatibleInputTypeBehaviour == IncompatibleInputTypeBehaviour.Exception)
                    {
                        throw new OperationStackExecutionException("Invalid input coming from " + PreviousBlockSpec?.Tag ?? "unknwon" + " block and going into " + CurrentBlockSpec.Tag + " block. Exception was " + e.Message);
                    }
                    else if (options.IncompatibleInputTypeBehaviour == IncompatibleInputTypeBehaviour.AssumeEmpty)
                    {
                        NextInput = Emptyable.Empty;
                    }
                    else if (options.IncompatibleInputTypeBehaviour == IncompatibleInputTypeBehaviour.Fail)
                    {
                        IsFail = true;
                        var error = ExceptionErrorBuilder <TOperationEvent> .Build(new OperationStackExecutionException("Invalid input coming from " + PreviousBlockSpec?.Tag ?? "unknwon" + " block and going into " + CurrentBlockSpec.Tag + " block. Exception was " + e.Message));

                        StackTrace.Add(new BlockTraceResult <TOperationEvent>(CurrentBlockSpec.Tag, error, NextInput));
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #2
0
 public void Throw(Exception exception)
 {
     Throw(ExceptionErrorBuilder <TOperationEvent> .Build(exception));
 }
Example #3
0
 public void Add(Exception exception)
 {
     Add(ExceptionErrorBuilder <TOperationEvent> .Build(exception));
 }