@@ -179,7 +179,7 @@ public override void BindBytes(ref byte[] obj, int maxLength = DefaultMaxLength)
179179 public override void Bind < T > ( ref T [ ] obj , Binder < T > bind , int maxLength = DefaultMaxLength )
180180 {
181181 int len = reader . ReadInt32 ( ) ;
182- if ( len > maxLength && maxLength != - 1 ) throw new ReaderException ( "Object too big") ;
182+ if ( len > maxLength && maxLength != - 1 ) throw new ReaderException ( $ "Array too big ( { len } > { maxLength } ) ") ;
183183
184184 obj = new T [ len ] ;
185185 for ( var i = 0 ; i < len ; i ++ )
@@ -192,14 +192,14 @@ public override void Bind<T>(ref T[] obj, Binder<T> bind, int maxLength = Defaul
192192
193193 public override void BindRemaining ( ref byte [ ] obj , int maxLength = DefaultMaxLength )
194194 {
195- if ( reader . Left > maxLength ) throw new ReaderException ( "Object too big") ;
195+ if ( reader . Left > maxLength ) throw new ReaderException ( $ "Remaining bytes too big ( { reader . Left } > { maxLength } ) ") ;
196196 obj = reader . ReadRaw ( reader . Left ) ;
197197 }
198198
199199 public override void Bind < T > ( ref List < T > obj , Binder < T > bind , int maxLength = DefaultMaxLength )
200200 {
201201 int len = reader . ReadInt32 ( ) ;
202- if ( len > maxLength ) throw new ReaderException ( "Object too big") ;
202+ if ( len > maxLength ) throw new ReaderException ( $ "List too big ( { len } > { maxLength } ) ") ;
203203
204204 obj = new List < T > ( len ) ;
205205 for ( var i = 0 ; i < len ; i ++ )
@@ -214,7 +214,7 @@ public override void Bind<K, V>(ref Dictionary<K, V> obj, Binder<K> bindKey, Bin
214214 int maxLength = DefaultMaxLength )
215215 {
216216 int len = reader . ReadInt32 ( ) ;
217- if ( len > maxLength && maxLength != - 1 ) throw new ReaderException ( "Object too big") ;
217+ if ( len > maxLength && maxLength != - 1 ) throw new ReaderException ( $ "Dictionary too big ( { len } > { maxLength } ) ") ;
218218
219219 obj = new Dictionary < K , V > ( len ) ;
220220 for ( int i = 0 ; i < len ; i ++ )
@@ -260,7 +260,7 @@ public sealed class PacketWriter(ByteWriter writer) : PacketBuffer(true)
260260
261261 public override void Bind ( ref string obj , int maxLength = DefaultMaxLength )
262262 {
263- if ( obj != null && obj . Length > maxLength ) throw new WriterException ( "Too long string" ) ;
263+ if ( obj != null && obj . Length > maxLength ) throw new WriterException ( $ "Too long string ( { obj . Length } > { maxLength } ) ") ;
264264 writer . WriteString ( obj ) ;
265265 }
266266
@@ -274,7 +274,7 @@ public override void BindBytes(ref byte[] obj, int maxLength = DefaultMaxLength)
274274
275275 public override void Bind < T > ( ref T [ ] obj , Binder < T > bind , int maxLength = DefaultMaxLength )
276276 {
277- if ( obj . Length > maxLength ) throw new WriterException ( "Object too big") ;
277+ if ( obj . Length > maxLength ) throw new WriterException ( $ "Array too big ( { obj . Length } > { maxLength } ) ") ;
278278 writer . WriteInt32 ( obj . Length ) ;
279279 for ( var i = 0 ; i < obj . Length ; i ++ )
280280 {
@@ -284,13 +284,13 @@ public override void Bind<T>(ref T[] obj, Binder<T> bind, int maxLength = Defaul
284284
285285 public override void BindRemaining ( ref byte [ ] obj , int maxLength = DefaultMaxLength )
286286 {
287- if ( obj . Length > maxLength ) throw new WriterException ( "Object too big") ;
287+ if ( obj . Length > maxLength ) throw new WriterException ( $ "Remaining bytes too big ( { obj . Length } > { maxLength } ) ") ;
288288 writer . WriteRaw ( obj ) ;
289289 }
290290
291291 public override void Bind < T > ( ref List < T > obj , Binder < T > bind , int maxLength = DefaultMaxLength )
292292 {
293- if ( obj . Count > maxLength ) throw new WriterException ( "Object too big") ;
293+ if ( obj . Count > maxLength ) throw new WriterException ( $ "List too big ( { obj . Count } > { maxLength } ) ") ;
294294 writer . WriteInt32 ( obj . Count ) ;
295295 for ( var i = 0 ; i < obj . Count ; i ++ )
296296 {
@@ -302,7 +302,7 @@ public override void Bind<T>(ref List<T> obj, Binder<T> bind, int maxLength = De
302302 public override void Bind < K , V > ( ref Dictionary < K , V > obj , Binder < K > bindKey , Binder < V > bindValue ,
303303 int maxLength = DefaultMaxLength )
304304 {
305- if ( obj . Count > maxLength ) throw new WriterException ( "Object too big") ;
305+ if ( obj . Count > maxLength ) throw new WriterException ( $ "Dictionary too big ( { obj . Count } > { maxLength } ) ") ;
306306 writer . WriteInt32 ( obj . Count ) ;
307307 foreach ( var ( key , value ) in obj )
308308 {
0 commit comments