From 82ba08b472dd2d2104614cc699a0a936f080f110 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 25 Sep 2023 14:08:00 +0200 Subject: [PATCH] CoapClientExcpeiton - Added new base class for any client-based errors RequestTimeoutException - Added new exception type --- source/doap/client/exceptions.d | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 source/doap/client/exceptions.d diff --git a/source/doap/client/exceptions.d b/source/doap/client/exceptions.d new file mode 100644 index 0000000..60a7ad2 --- /dev/null +++ b/source/doap/client/exceptions.d @@ -0,0 +1,44 @@ +module doap.client.exceptions; + +import doap.exceptions : CoapException; +import core.time : Duration; + +public class CoapClientException : CoapException +{ + this(string msg) + { + super(msg); + } +} + +import doap.client.request : CoapRequestFuture; +import std.conv : to; + +package final class RequestTimeoutException : CoapClientException +{ + /** + * The future we timed out on + */ + private CoapRequestFuture future; + + /** + * Timeout time + */ + private Duration timeout; + + /** + * Constructs a new timeout exception for + * the given future which timed out + * + * Params: + * future = the future we timed out on + * timeout = the time duration timed out + * on + */ + this(CoapRequestFuture future, Duration timeout) + { + super("Timed out whilst waiting for "~to!(string)(future)~" after "~to!(string)(timeout)); + this.future = future; + this.timeout = timeout; + } +} \ No newline at end of file