@@ -34,11 +34,14 @@ public void Serialize(Stream stream, IElasticsearchClientSettings settings, Seri
34
34
foreach ( var op in Operations )
35
35
{
36
36
if ( op is not IStreamSerializable serializable )
37
- throw new InvalidOperationException ( "" ) ;
37
+ {
38
+ ThrowHelper . ThrowInvalidOperationForBulkWhenNotIStreamSerializable ( ) ;
39
+ return ;
40
+ }
38
41
39
42
op . PrepareIndex ( index ) ;
40
43
41
- serializable . Serialize ( stream , settings , formatting ) ;
44
+ serializable . Serialize ( stream , settings , SerializationFormatting . None ) ;
42
45
stream . WriteByte ( ( byte ) '\n ' ) ;
43
46
}
44
47
}
@@ -53,11 +56,14 @@ public async Task SerializeAsync(Stream stream, IElasticsearchClientSettings set
53
56
foreach ( var op in Operations )
54
57
{
55
58
if ( op is not IStreamSerializable serializable )
56
- throw new InvalidOperationException ( "" ) ;
59
+ {
60
+ ThrowHelper . ThrowInvalidOperationForBulkWhenNotIStreamSerializable ( ) ;
61
+ return ;
62
+ }
57
63
58
64
op . PrepareIndex ( index ) ;
59
65
60
- await serializable . SerializeAsync ( stream , settings , formatting ) . ConfigureAwait ( false ) ;
66
+ await serializable . SerializeAsync ( stream , settings , SerializationFormatting . None ) . ConfigureAwait ( false ) ;
61
67
stream . WriteByte ( ( byte ) '\n ' ) ;
62
68
}
63
69
}
@@ -200,11 +206,14 @@ public void Serialize(Stream stream, IElasticsearchClientSettings settings, Seri
200
206
foreach ( var op in _operations )
201
207
{
202
208
if ( op is not IStreamSerializable serializable )
203
- throw new InvalidOperationException ( "" ) ;
209
+ {
210
+ ThrowHelper . ThrowInvalidOperationForBulkWhenNotIStreamSerializable ( ) ;
211
+ return ;
212
+ }
204
213
205
214
op . PrepareIndex ( index ) ;
206
215
207
- serializable . Serialize ( stream , settings , formatting ) ;
216
+ serializable . Serialize ( stream , settings , SerializationFormatting . None ) ;
208
217
stream . WriteByte ( ( byte ) '\n ' ) ;
209
218
}
210
219
}
@@ -219,11 +228,14 @@ public async Task SerializeAsync(Stream stream, IElasticsearchClientSettings set
219
228
foreach ( var op in _operations )
220
229
{
221
230
if ( op is not IStreamSerializable serializable )
222
- throw new InvalidOperationException ( "" ) ;
231
+ {
232
+ ThrowHelper . ThrowInvalidOperationForBulkWhenNotIStreamSerializable ( ) ;
233
+ return ;
234
+ }
223
235
224
236
op . PrepareIndex ( index ) ;
225
237
226
- await serializable . SerializeAsync ( stream , settings , formatting ) . ConfigureAwait ( false ) ;
238
+ await serializable . SerializeAsync ( stream , settings , SerializationFormatting . None ) . ConfigureAwait ( false ) ;
227
239
stream . WriteByte ( ( byte ) '\n ' ) ;
228
240
}
229
241
}
0 commit comments