Add error description to exception message when read fails

This commit is contained in:
Maximilian Bachmeier
2019-12-03 10:37:12 +01:00
parent fd7dd01a5e
commit 9478e5cd9c

View File

@@ -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];