Esempio n. 1
0
        public static bool RunAndHandleException(Action <nspec> action, nspec instance, ref Exception targetException)
        {
            bool      hasThrown      = false;
            Exception exceptionToSet = null;

            try
            {
                action(instance);
            }
            catch (TargetInvocationException invocationException)
            {
                exceptionToSet = instance.ExceptionToReturn(invocationException.InnerException);

                hasThrown = true;
            }
            catch (Exception exception)
            {
                exceptionToSet = instance.ExceptionToReturn(exception);

                hasThrown = true;
            }

            if (targetException == null && exceptionToSet != null)
            {
                targetException = exceptionToSet;
            }

            return(hasThrown);
        }
Esempio n. 2
0
        public bool RunAndHandleException(Action <nspec> action, nspec nspec, ref Exception exceptionToSet)
        {
            bool hasThrown = false;

            try
            {
                action(nspec);
            }
            catch (TargetInvocationException invocationException)
            {
                if (exceptionToSet == null)
                {
                    exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException);
                }

                hasThrown = true;
            }
            catch (Exception exception)
            {
                if (exceptionToSet == null)
                {
                    exceptionToSet = nspec.ExceptionToReturn(exception);
                }

                hasThrown = true;
            }

            return(hasThrown);
        }
Esempio n. 3
0
 public void RunAndHandleException(Action <nspec> action, nspec nspec, ref Exception exceptionToSet)
 {
     try
     {
         action(nspec);
     }
     catch (TargetInvocationException invocationException)
     {
         if (exceptionToSet == null)
         {
             exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException);
         }
     }
     catch (Exception exception)
     {
         if (exceptionToSet == null)
         {
             exceptionToSet = nspec.ExceptionToReturn(exception);
         }
     }
 }
Esempio n. 4
0
 public void RunAndHandleException(Action<nspec> action, nspec nspec, ref Exception exceptionToSet)
 {
     try
     {
         action(nspec);
     }
     catch (TargetInvocationException invocationException)
     {
         if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException);
     }
     catch (Exception exception)
     {
         if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(exception);
     }
 }
Esempio n. 5
0
        public bool RunAndHandleException(Action<nspec> action, nspec nspec, ref Exception exceptionToSet)
        {
            bool hasThrown = false;

            try
            {
                action(nspec);
            }
            catch (TargetInvocationException invocationException)
            {
                if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException);

                hasThrown = true;
            }
            catch (Exception exception)
            {
                if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(exception);

                hasThrown = true;
            }

            return hasThrown;
        }