248
|
1 using System;
|
|
2
|
|
3 namespace Implab
|
|
4 {
|
|
5 public struct RejectedPromise : IPromise {
|
|
6 readonly Exception m_reason;
|
|
7
|
|
8 public Type ResultType => typeof(void);
|
|
9
|
|
10 public bool IsResolved => true;
|
|
11
|
|
12 public bool IsRejected => true;
|
|
13
|
|
14 public bool IsFulfilled => false;
|
|
15
|
|
16 public Exception RejectReason => m_reason;
|
|
17
|
|
18 public RejectedPromise(Exception reason) {
|
|
19 m_reason = reason;
|
|
20 }
|
|
21
|
|
22 public IPromise<T> Cast<T>() {
|
|
23 throw new InvalidCastException();
|
|
24 }
|
|
25
|
|
26 public void Join() {
|
249
|
27 throw m_reason.Wrap();
|
248
|
28 }
|
|
29
|
|
30 public void Join(int timeout) {
|
249
|
31 throw m_reason.Wrap();
|
248
|
32 }
|
|
33
|
|
34 public void Then(IResolvable next) {
|
|
35 next.Reject(m_reason);
|
|
36 }
|
|
37 }
|
|
38 } |