1 module doap.client.exceptions;
2 
3 import doap.exceptions : CoapException;
4 import core.time : Duration;
5 
6 public class CoapClientException : CoapException
7 {
8     this(string msg)
9     {
10         super(msg);
11     }
12 }
13 
14 import doap.client.request : CoapRequestFuture;
15 import std.conv : to;
16 
17 /** 
18  * Thrown when a `CoapRequestFuture` has
19  * a `get(Duration)` call timeout
20  */
21 public final class RequestTimeoutException : CoapClientException
22 {
23     /** 
24      * The future we timed out on
25      */
26     private CoapRequestFuture future;
27 
28     /**
29      * Timeout time
30      */
31     private Duration timeout;
32 
33     /** 
34      * Constructs a new timeout exception for
35      * the given future which timed out
36      *
37      * Params:
38      *   future = the future we timed out on
39      *   timeout = the time duration timed out
40      * on
41      */
42     package this(CoapRequestFuture future, Duration timeout)
43     {
44         super("Timed out whilst waiting for "~to!(string)(future)~" after "~to!(string)(timeout));
45         this.future = future;
46         this.timeout = timeout;
47     }
48 
49     /** 
50      * Returns the future request which timed
51      * out and cause dthis exception to throw
52      * in the first place
53      *
54      * Returns: the `CoapRequestFuture`
55      */
56     public CoapRequestFuture getFuture()
57     {
58         return this.future;
59     }
60 
61     /** 
62      * Returns the timeout period which 
63      * was exceeded
64      *
65      * Returns: the `Duration`
66      */
67     public Duration getTimeout()
68     {
69         return this.timeout;
70     }
71 }