Skip to content

Commit be0c4a2

Browse files
committed
Replaced CapacityException with NotSupportedException
This is to follow the general convention set by the MemoryStream class
1 parent ed5d7a7 commit be0c4a2

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

MLAPI.Tests/NetworkingManagerComponents/Binary/BitStreamTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void TestGrow()
3535
BitStream bitStream = new BitStream(new byte[0]);
3636
Assert.That(
3737
() => { bitStream.WriteInt64(long.MaxValue); },
38-
Throws.TypeOf<CapacityException>());
38+
Throws.TypeOf<NotSupportedException>());
3939
}
4040

4141
[Test]

MLAPI/NetworkingManagerComponents/Binary/BitStream.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public override long Seek(long offset, SeekOrigin origin)
194194
/// <param name="value">New capacity of the buffer</param>
195195
private void SetCapacity(long value)
196196
{
197-
if (!Resizable) throw new CapacityException("Can't resize fixed-capacity buffer! Capacity (bytes): "+target.Length); // Don't do shit because fuck you
197+
if (!Resizable) throw new NotSupportedException("Can't resize non resizable buffer"); // Don't do shit because fuck you (comment by @GabrielTofvesson -TwoTen)
198198
byte[] newTarg = new byte[value];
199199
long len = Math.Min(value, target.LongLength);
200200
Buffer.BlockCopy(target, 0, newTarg, 0, (int)len);
@@ -678,15 +678,5 @@ public byte[] ToArray()
678678
/// </summary>
679679
/// <returns>Hex encoded version of the buffer</returns>
680680
public override string ToString() => BitConverter.ToString(target, 0, (int)Length);
681-
682-
/// <summary>
683-
/// An exception representing cases when buffer-capacity related errors occur.
684-
/// </summary>
685-
public sealed class CapacityException : Exception
686-
{
687-
public CapacityException() { }
688-
public CapacityException(string message) : base(message) { }
689-
public CapacityException(string message, Exception innerException) : base(message, innerException) { }
690-
}
691681
}
692682
}

0 commit comments

Comments
 (0)