diff Implab/ExceptionHelpers.cs @ 249:d82909310094 v3

Implab.Test moved to xunit Complete set of PromiseHelpers (Then, Catch, Finally) Removed obsolete types ICancellable, ICancellationToken
author cin
date Wed, 31 Jan 2018 11:28:38 +0300
parents 5cb4826c2c2a
children
line wrap: on
line diff
--- a/Implab/ExceptionHelpers.cs	Tue Jan 30 01:37:17 2018 +0300
+++ b/Implab/ExceptionHelpers.cs	Wed Jan 31 11:28:38 2018 +0300
@@ -3,16 +3,19 @@
 using System.Runtime.ExceptionServices;
 
 namespace Implab {
-    public static class ExceptionHelpers {
-        public static void Rethrow(this Exception that) {
+    static class ExceptionHelpers {
+        public static Exception Rethrow(this Exception that) {
             ExceptionDispatchInfo.Capture(that).Throw();
+            return new TargetInvocationException(that);
         }
 
-        public static void ThrowInvocationException(this Exception that) {
-            if (that is OperationCanceledException)
-                throw new OperationCanceledException("Operation cancelled", that);
+        public static Exception Wrap(this Exception that) {
+            if (that == null)
+                return new Exception();
+            else if (that is OperationCanceledException)
+                return new OperationCanceledException("The operation has been cancelled", that);
             else
-                throw new TargetInvocationException(that);
+                return new TargetInvocationException(that);
         }
     }
 }
\ No newline at end of file