@@ -42,7 +42,7 @@ public static int WriteLittleEndian<T>(this IBufferWriter<byte> writer, T value)
42
42
for ( var destination = writer . GetSpan ( ) ; ! value . TryWriteLittleEndian ( destination , out length ) ; destination = writer . GetSpan ( length ) )
43
43
{
44
44
length = destination . Length ;
45
- length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ) ;
45
+ length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
46
46
}
47
47
48
48
writer . Advance ( length ) ;
@@ -64,7 +64,7 @@ public static int WriteBigEndian<T>(this IBufferWriter<byte> writer, T value)
64
64
for ( var destination = writer . GetSpan ( ) ; ! value . TryWriteBigEndian ( destination , out length ) ; destination = writer . GetSpan ( length ) )
65
65
{
66
66
length = destination . Length ;
67
- length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ) ;
67
+ length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
68
68
}
69
69
70
70
writer . Advance ( length ) ;
@@ -84,7 +84,7 @@ public static int Write(this IBufferWriter<byte> writer, in BigInteger value, bo
84
84
{
85
85
var buffer = writer . GetSpan ( value . GetByteCount ( isUnsigned ) ) ;
86
86
if ( ! value . TryWriteBytes ( buffer , out var bytesWritten , isUnsigned , isBigEndian ) )
87
- throw new InsufficientMemoryException ( ) ;
87
+ throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
88
88
89
89
writer . Advance ( bytesWritten ) ;
90
90
return bytesWritten ;
@@ -108,7 +108,7 @@ public static int Format<T>(this IBufferWriter<byte> writer, T value, ReadOnlySp
108
108
for ( int sizeHint ; ! value . TryFormat ( buffer , out bytesWritten , format , provider ) ; buffer = writer . GetSpan ( sizeHint ) )
109
109
{
110
110
sizeHint = buffer . Length ;
111
- sizeHint = sizeHint <= MaxBufferSize ? sizeHint << 1 : throw new InsufficientMemoryException ( ) ;
111
+ sizeHint = sizeHint <= MaxBufferSize ? sizeHint << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
112
112
}
113
113
114
114
writer . Advance ( bytesWritten ) ;
@@ -143,7 +143,7 @@ public static int WriteLittleEndian<T>(this ref BufferWriterSlim<byte> writer, T
143
143
for ( var destination = writer . InternalGetSpan ( sizeHint : 0 ) ; ! value . TryWriteLittleEndian ( destination , out length ) ; destination = writer . InternalGetSpan ( length ) )
144
144
{
145
145
length = destination . Length ;
146
- length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ) ;
146
+ length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
147
147
}
148
148
149
149
writer . Advance ( length ) ;
@@ -165,7 +165,7 @@ public static int WriteBigEndian<T>(this ref BufferWriterSlim<byte> writer, T va
165
165
for ( var destination = writer . InternalGetSpan ( sizeHint : 0 ) ; ! value . TryWriteBigEndian ( destination , out length ) ; destination = writer . InternalGetSpan ( length ) )
166
166
{
167
167
length = destination . Length ;
168
- length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ) ;
168
+ length = length <= MaxBufferSize ? length << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
169
169
}
170
170
171
171
writer . Advance ( length ) ;
@@ -185,7 +185,7 @@ public static int Write(this ref BufferWriterSlim<byte> writer, in BigInteger va
185
185
{
186
186
var buffer = writer . InternalGetSpan ( value . GetByteCount ( isUnsigned ) ) ;
187
187
if ( ! value . TryWriteBytes ( buffer , out var bytesWritten , isUnsigned , isBigEndian ) )
188
- throw new InsufficientMemoryException ( ) ;
188
+ throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
189
189
190
190
writer . Advance ( bytesWritten ) ;
191
191
return bytesWritten ;
@@ -209,7 +209,7 @@ public static int Format<T>(this ref BufferWriterSlim<byte> writer, T value, Rea
209
209
for ( int sizeHint ; ! value . TryFormat ( buffer , out bytesWritten , format , provider ) ; buffer = writer . InternalGetSpan ( sizeHint ) )
210
210
{
211
211
sizeHint = buffer . Length ;
212
- sizeHint = sizeHint <= MaxBufferSize ? sizeHint << 1 : throw new InsufficientMemoryException ( ) ;
212
+ sizeHint = sizeHint <= MaxBufferSize ? sizeHint << 1 : throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
213
213
}
214
214
215
215
writer . Advance ( bytesWritten ) ;
@@ -258,7 +258,7 @@ public static int WriteLittleEndian<T>(this ref SpanWriter<byte> writer, T value
258
258
where T : notnull , IBinaryInteger < T >
259
259
{
260
260
if ( ! value . TryWriteLittleEndian ( writer . RemainingSpan , out var bytesWritten ) )
261
- throw new InsufficientMemoryException ( ) ;
261
+ throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
262
262
263
263
writer . Advance ( bytesWritten ) ;
264
264
return bytesWritten ;
@@ -276,7 +276,7 @@ public static int WriteBigEndian<T>(this ref SpanWriter<byte> writer, T value)
276
276
where T : notnull , IBinaryInteger < T >
277
277
{
278
278
if ( ! value . TryWriteBigEndian ( writer . RemainingSpan , out var bytesWritten ) )
279
- throw new InsufficientMemoryException ( ) ;
279
+ throw new InsufficientMemoryException ( ExceptionMessages . NotEnoughMemory ) ;
280
280
281
281
writer . Advance ( bytesWritten ) ;
282
282
return bytesWritten ;
0 commit comments