From 9478e5cd9cb69fa012039b9ac742df96033f0459 Mon Sep 17 00:00:00 2001 From: Maximilian Bachmeier Date: Tue, 3 Dec 2019 10:37:12 +0100 Subject: [PATCH] Add error description to exception message when read fails --- Sharp7.Rx/Sharp7Connector.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sharp7.Rx/Sharp7Connector.cs b/Sharp7.Rx/Sharp7Connector.cs index 76009bd..34a9965 100644 --- a/Sharp7.Rx/Sharp7Connector.cs +++ b/Sharp7.Rx/Sharp7Connector.cs @@ -185,7 +185,8 @@ namespace Sharp7.Rx if (result != 0) { await EvaluateErrorCode(result); - throw new InvalidOperationException($"Error reading {operand}{dBNr}:{startByteAddress}->{bytesToRead}"); + var errorText = this.sharp7.ErrorText(result); + throw new InvalidOperationException($"Error reading {operand}{dBNr}:{startByteAddress}->{bytesToRead} ({errorText})"); } var retBuffer = new byte[bytesToRead];