From 8a97fecddd3b380cd0c1fe042c6e499ec5c8435a Mon Sep 17 00:00:00 2001 From: drieseng Date: Mon, 15 Aug 2016 12:41:04 +0200 Subject: [PATCH] Improve exception message when attempting to read more bytes than available. --- src/Renci.SshNet/Common/SshDataStream.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Renci.SshNet/Common/SshDataStream.cs b/src/Renci.SshNet/Common/SshDataStream.cs index df37d254..36ee3f8f 100644 --- a/src/Renci.SshNet/Common/SshDataStream.cs +++ b/src/Renci.SshNet/Common/SshDataStream.cs @@ -220,7 +220,9 @@ namespace Renci.SshNet.Common var bytesRead = Read(data, 0, length); if (bytesRead < length) - throw new ArgumentOutOfRangeException("length"); + throw new ArgumentOutOfRangeException("length", + string.Format(CultureInfo.InvariantCulture, + "The requested length ({0}) is greater than the actual number of bytes read ({1}).", length, bytesRead)); return data; }