From d1e1297a2605568486a84fc4b9f7a4dea43dff3d Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Fri, 4 Dec 2020 14:11:55 +0200 Subject: [PATCH] Handle error --- source/dnetd/dplugin.d | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/source/dnetd/dplugin.d b/source/dnetd/dplugin.d index 5c8f659..b1a34e9 100644 --- a/source/dnetd/dplugin.d +++ b/source/dnetd/dplugin.d @@ -54,19 +54,23 @@ public final class DPlugin /* TODO: Error handling */ status = sendMessage(socket, data); - /* Get the reply */ - /* TODO: Error handling */ - byte[] reply; - receiveMessage(socket, reply); - - /* Close the connetion to the plugin server */ - socket.close(); - /* Encode the status in the reply */ response ~= [status]; - /* Encode the response */ - response ~= reply; + /* If the send succeeded */ + if(status) + { + /* Get the reply */ + /* TODO: Error handling */ + byte[] reply; + receiveMessage(socket, reply); + + /* Close the connetion to the plugin server */ + socket.close(); + + /* Encode the response */ + response ~= reply; + } return response; }