From 46466782765e986bda9c1ed7432cad2dc00c2f8a Mon Sep 17 00:00:00 2001 From: Bill Menees Date: Wed, 14 Sep 2022 05:11:29 -0500 Subject: [PATCH] Use EndOfStreamException for truncated reads --- src/Directory.Build.props | 2 +- src/Menees.Remoting/Models/Message.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 32d2e74..efe0e87 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -29,7 +29,7 @@ - 0.5.0-beta + 0.6.0-beta diff --git a/src/Menees.Remoting/Models/Message.cs b/src/Menees.Remoting/Models/Message.cs index 9c7a6cf..9abb382 100644 --- a/src/Menees.Remoting/Models/Message.cs +++ b/src/Menees.Remoting/Models/Message.cs @@ -105,7 +105,7 @@ private static byte[] RequireRead(Stream stream, int requiredCount, string forWh if (totalCount != requiredCount) { - throw new ArgumentException( + throw new EndOfStreamException( $"Unable to read {requiredCount} byte {forWhat} from stream. Only {totalCount} bytes were available."); } @@ -154,7 +154,7 @@ void ThrowIfCancellationRequested() if (totalCount != requiredCount) { ThrowIfCancellationRequested(); - throw new ArgumentException( + throw new EndOfStreamException( $"Unable to read {requiredCount} byte {forWhat} from stream. Only {totalCount} bytes were available."); }