| 248 | 1 using System; | 
|  | 2 using System.Reflection; | 
|  | 3 using System.Runtime.ExceptionServices; | 
|  | 4 | 
|  | 5 namespace Implab { | 
| 249 | 6     static class ExceptionHelpers { | 
|  | 7         public static Exception Rethrow(this Exception that) { | 
| 248 | 8             ExceptionDispatchInfo.Capture(that).Throw(); | 
| 249 | 9             return new TargetInvocationException(that); | 
| 248 | 10         } | 
|  | 11 | 
| 249 | 12         public static Exception Wrap(this Exception that) { | 
|  | 13             if (that == null) | 
|  | 14                 return new Exception(); | 
|  | 15             else if (that is OperationCanceledException) | 
|  | 16                 return new OperationCanceledException("The operation has been cancelled", that); | 
| 248 | 17             else | 
| 249 | 18                 return new TargetInvocationException(that); | 
| 248 | 19         } | 
|  | 20     } | 
|  | 21 } |