Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/guiunit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan McGovern <alan@xamarin.com>2013-07-24 19:43:19 +0400
committerAlan McGovern <alan@xamarin.com>2013-07-24 19:43:19 +0400
commit8cf1247d2865377219f076e82346a7909fa395ae (patch)
tree6e0662ea57d20f696e69b420c69cad453b74075c
parentc60ba41b30196269d6dcef5ae8d9eceaec8aa83e (diff)
Better propagation of async exceptions
If we have an exception from an Async test we need to get it from the AggregateException and propagate it properly.
-rwxr-xr-xsrc/framework/Internal/Reflect.cs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/framework/Internal/Reflect.cs b/src/framework/Internal/Reflect.cs
index 37113c9..1e18409 100755
--- a/src/framework/Internal/Reflect.cs
+++ b/src/framework/Internal/Reflect.cs
@@ -225,20 +225,30 @@ namespace NUnit.Framework.Internal
if (invokeHelper.Result is System.Threading.Tasks.Task)
((System.Threading.Tasks.Task)invokeHelper.Result).Wait ();
+ else if (invokeHelper.ex != null)
+ Rethrow (invokeHelper.ex);
return invokeHelper.Result;
}
catch(Exception e)
{
- if (e is TargetInvocationException)
- throw new NUnitException("Rethrown", e.InnerException);
- else
- throw new NUnitException("Rethrown", e);
+ Rethrow (e);
}
}
return null;
}
+ static void Rethrow (Exception e)
+ {
+ string Rethrown = "Rethrown";
+ if (e is NUnitException && e.Message == Rethrown)
+ throw e;
+
+ if (e is TargetInvocationException || e is AggregateException)
+ throw new NUnitException(Rethrown, e.InnerException);
+ else
+ throw new NUnitException(Rethrown, e);
+ }
#endregion
#region Private Constructor for static-only class