Esempio n. 1
0
 // TODO: we propagate an unhandled exception during an operation back to the task, should we handle it differently?
 private void BodyFaultCallback(NativeActivityFaultContext context, Exception propagatedException, ActivityInstance propagatedFrom)
 {
     if (!context.GetReceiveRequestSendResponseScopeExecutionProperty().TrySetTaskCompletionSourceException(propagatedException))
     {
         // this will add a WorkflowInstanceAbortedRecord with the reason
         context.Abort(propagatedException);
     }
     else
     {
         // this won't add any WorkflowInstanceAbortedRecord at all
         context.Abort();
     }
     context.HandleFault();
 }
Esempio n. 2
0
        private void OnExceptionFromHandler(NativeActivityFaultContext context, Exception propagatedException, ActivityInstance propagatedFrom)
        {
            var compensationExtension = context.GetExtension <CompensationExtension>();

            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            var compensationToken = compensationExtension.Get(this.compensationId.Get(context));

            Fx.Assert(compensationToken != null, "CompensationTokenData must be valid");

            InvalidOperationException exception = null;

            switch (compensationToken.CompensationState)
            {
            case CompensationState.Confirming:
                exception = new InvalidOperationException(SR.ConfirmationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                break;

            case CompensationState.Compensating:
                exception = new InvalidOperationException(SR.CompensationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                break;

            case CompensationState.Canceling:
                exception = new InvalidOperationException(SR.CancellationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                break;

            default:
                Fx.Assert(false, "CompensationState is in unexpected state!");
                break;
            }

            context.Abort(exception);
        }
Esempio n. 3
0
        void OnExceptionFromTry(NativeActivityFaultContext context, Exception propagatedException, ActivityInstance propagatedFrom)
        {
            if (propagatedFrom.IsCancellationRequested)
            {
                if (TD.TryCatchExceptionDuringCancelationIsEnabled())
                {
                    TD.TryCatchExceptionDuringCancelation(this.DisplayName);
                }

                // The Try activity threw an exception during Cancel; abort the workflow
                context.Abort(propagatedException);
                context.HandleFault();
            }
            else
            {
                Catch catchHandler = FindCatch(propagatedException);
                if (catchHandler != null)
                {
                    if (TD.TryCatchExceptionFromTryIsEnabled())
                    {
                        TD.TryCatchExceptionFromTry(this.DisplayName, propagatedException.GetType().ToString());
                    }

                    context.CancelChild(propagatedFrom);
                    TryCatchState state = this.state.Get(context);

                    // If we are not supposed to persist exceptions, enter our noPersistScope
                    ExceptionPersistenceExtension extension = context.GetExtension <ExceptionPersistenceExtension>();
                    if ((extension != null) && !extension.PersistExceptions)
                    {
                        NoPersistProperty noPersistProperty = (NoPersistProperty)context.Properties.FindAtCurrentScope(NoPersistProperty.Name);
                        if (noPersistProperty != null)
                        {
                            // The property will be exited when the activity completes or aborts.
                            noPersistProperty.Enter();
                        }
                    }

                    state.CaughtException = context.CreateFaultContext();
                    context.HandleFault();
                }
            }
        }
        private void OnExceptionFromHandler(NativeActivityFaultContext context, Exception propagatedException, System.Activities.ActivityInstance propagatedFrom)
        {
            CompensationTokenData     data   = context.GetExtension <CompensationExtension>().Get(this.compensationId.Get(context));
            InvalidOperationException reason = null;

            switch (data.CompensationState)
            {
            case CompensationState.Confirming:
                reason = new InvalidOperationException(System.Activities.SR.ConfirmationHandlerFatalException(data.DisplayName), propagatedException);
                break;

            case CompensationState.Compensating:
                reason = new InvalidOperationException(System.Activities.SR.CompensationHandlerFatalException(data.DisplayName), propagatedException);
                break;

            case CompensationState.Canceling:
                reason = new InvalidOperationException(System.Activities.SR.CancellationHandlerFatalException(data.DisplayName), propagatedException);
                break;
            }
            context.Abort(reason);
        }
 private void OnExceptionFromTry(NativeActivityFaultContext context, Exception propagatedException, System.Activities.ActivityInstance propagatedFrom)
 {
     if (propagatedFrom.IsCancellationRequested)
     {
         if (TD.TryCatchExceptionDuringCancelationIsEnabled())
         {
             TD.TryCatchExceptionDuringCancelation(base.DisplayName);
         }
         context.Abort(propagatedException);
         context.HandleFault();
     }
     else if (this.FindCatch(propagatedException) != null)
     {
         if (TD.TryCatchExceptionFromTryIsEnabled())
         {
             TD.TryCatchExceptionFromTry(base.DisplayName, propagatedException.GetType().ToString());
         }
         context.CancelChild(propagatedFrom);
         this.state.Get(context).CaughtException = context.CreateFaultContext();
         context.HandleFault();
     }
 }
        void OnExceptionFromHandler(NativeActivityFaultContext context, Exception propagatedException, ActivityInstance propagatedFrom)
        {
            CompensationExtension compensationExtension = context.GetExtension<CompensationExtension>();
            Fx.Assert(compensationExtension != null, "CompensationExtension must be valid");

            CompensationTokenData compensationToken = compensationExtension.Get(this.compensationId.Get(context));
            Fx.Assert(compensationToken != null, "CompensationTokenData must be valid");

            InvalidOperationException exception = null;

            switch (compensationToken.CompensationState)
            {
                case CompensationState.Confirming:
                    exception = new InvalidOperationException(SR.ConfirmationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                    break;
                case CompensationState.Compensating:
                    exception = new InvalidOperationException(SR.CompensationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                    break;
                case CompensationState.Canceling:
                    exception = new InvalidOperationException(SR.CancellationHandlerFatalException(compensationToken.DisplayName), propagatedException);
                    break;
                default:
                    Fx.Assert(false, "CompensationState is in unexpected state!");
                    break;
            }

            context.Abort(exception);
        }