Skip to content

Commit c299efb

Browse files
committed
fix Send<T> to do not fail on deserialization error
1 parent 8448fe8 commit c299efb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/NBomber.Http/FSharp.fs

+8-2
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,17 @@ module Http =
193193

194194
let body = response.Content.ReadAsStreamAsync().Result
195195
let jsonOptions = clientArgs.JsonSerializerOptions |> Option.defaultValue GlobalJsonSerializerOptions
196-
let value = JsonSerializer.Deserialize<'T>(body, jsonOptions)
196+
197+
let value =
198+
try
199+
JsonSerializer.Deserialize<'T>(body, jsonOptions)
200+
with
201+
_ -> Unchecked.defaultof<_>
202+
197203
let httpRes = { Data = value; Response = response }
198204

199205
return
200-
if response.IsSuccessStatusCode then
206+
if response.IsSuccessStatusCode then
201207
Response.ok(statusCode = response.StatusCode.ToString(), sizeBytes = dataSize, payload = httpRes)
202208
else
203209
Response.fail(statusCode = response.StatusCode.ToString(), sizeBytes = dataSize, payload = httpRes)

0 commit comments

Comments
 (0)