annotate Implab/ExceptionHelpers.cs @ 248:5cb4826c2c2a v3

Added awaiters to promises Added static methods to Promise Resolve, Reject, All. Updated promise helpers
author cin
date Tue, 30 Jan 2018 01:37:17 +0300
parents
children d82909310094
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
1 using System;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
2 using System.Reflection;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
3 using System.Runtime.ExceptionServices;
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
4
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
5 namespace Implab {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
6 public static class ExceptionHelpers {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
7 public static void Rethrow(this Exception that) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
8 ExceptionDispatchInfo.Capture(that).Throw();
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
9 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
10
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
11 public static void ThrowInvocationException(this Exception that) {
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
12 if (that is OperationCanceledException)
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
13 throw new OperationCanceledException("Operation cancelled", that);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
14 else
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
15 throw new TargetInvocationException(that);
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
16 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
17 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
18 }