| 248 | 1 using System; | 
|  | 2 | 
|  | 3 namespace Implab | 
|  | 4 { | 
|  | 5     public struct RejectedPromise<T> : IPromise<T> { | 
|  | 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<T2> Cast<T2>() { | 
|  | 23             return (IPromise<T2>)(IPromise<T>)this; | 
|  | 24         } | 
|  | 25 | 
|  | 26         void IPromise.Join() { | 
| 249 | 27             throw m_reason.Wrap(); | 
| 248 | 28         } | 
|  | 29 | 
|  | 30         void IPromise.Join(int timeout) { | 
| 249 | 31             throw m_reason.Wrap(); | 
| 248 | 32         } | 
|  | 33 | 
|  | 34         public T Join() { | 
| 249 | 35             throw m_reason.Wrap(); | 
| 248 | 36         } | 
|  | 37 | 
|  | 38         public T Join(int timeout) { | 
| 249 | 39             throw m_reason.Wrap(); | 
| 248 | 40         } | 
|  | 41 | 
|  | 42         public void Then(IResolvable next) { | 
|  | 43             next.Reject(m_reason); | 
|  | 44         } | 
|  | 45 | 
|  | 46         public void Then(IResolvable<T> next) { | 
|  | 47             next.Reject(m_reason); | 
|  | 48         } | 
|  | 49     } | 
|  | 50 } |