annotate Implab/ExceptionHelpers.cs @ 278:6691aff01de1 v3

Implab: added XmlDefaultSeializer (SerializersPool is now obsolete) Implab.ServiceHost: rewritten TypeReference (added support for nested types), stable API
author cin
date Thu, 03 May 2018 09:59:44 +0300
parents d82909310094
children
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 {
249
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
6 static class ExceptionHelpers {
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
7 public static Exception Rethrow(this Exception that) {
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
8 ExceptionDispatchInfo.Capture(that).Throw();
249
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
9 return new TargetInvocationException(that);
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
10 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
11
249
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
12 public static Exception Wrap(this Exception that) {
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
13 if (that == null)
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
14 return new Exception();
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
15 else if (that is OperationCanceledException)
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
16 return new OperationCanceledException("The operation has been cancelled", that);
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
17 else
249
d82909310094 Implab.Test moved to xunit
cin
parents: 248
diff changeset
18 return new TargetInvocationException(that);
248
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
19 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
20 }
5cb4826c2c2a Added awaiters to promises
cin
parents:
diff changeset
21 }