]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Add additional context for invalid ByteSpans
authorMatthew Endsley <mendsley@gmail.com>
Wed, 31 Mar 2021 18:56:47 +0000 (11:56 -0700)
committerMatthew Endsley <mendsley@gmail.com>
Wed, 31 Mar 2021 18:56:47 +0000 (11:56 -0700)
Hazel/ByteSpan.cs

index 9d3319300300ab080cfd096e66226167568f9c80..506b1538fe12e824bdaaa7df5737ceb229e44b78 100644 (file)
@@ -54,9 +54,13 @@ namespace Hazel
                 {
                     throw new ArgumentException("Invalid offset", nameof(offset));
                 }
-                if (length < 0 || (offset + length) > array.Length)
+                if (length < 0)
                 {
-                    throw new ArgumentException("Invalid length", nameof(length));
+                    throw new ArgumentException($"Invalid length: {length}", nameof(length));
+                }
+                if ((offset + length) > array.Length)
+                {
+                    throw new ArgumentException($"Invalid length. Length: {length} Offset: {offset} Array size: {array.Length}", nameof(length));
                 }
 
                 this.array_ = array;