Skip to content

Commit c3c8b60

Browse files
DanielW093grdsdev
authored andcommitted
Fixed issue when making non get requests
1 parent 79c92b6 commit c3c8b60

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Postgrest/Responses/ModeledResponse.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,18 @@ public ModeledResponse(BaseResponse baseResponse, JsonSerializerSettings seriali
7676
break;
7777
}
7878
}
79-
80-
var countStr = baseResponse.ResponseMessage?.Content.Headers.GetValues("Content-Range").FirstOrDefault();
81-
Count = int.Parse(countStr?.Split('/')[1] ?? throw new InvalidOperationException());
79+
80+
try
81+
{
82+
var countStr = baseResponse.ResponseMessage?.Content.Headers.GetValues("Content-Range")
83+
.FirstOrDefault();
84+
Count = int.Parse(countStr?.Split('/')[1] ?? throw new InvalidOperationException());
85+
}
86+
catch (Exception e)
87+
{
88+
Debugger.Instance.Log(this, e.Message);
89+
Count = -1;
90+
}
8291

8392
Debugger.Instance.Log(this, $"Response: [{baseResponse.ResponseMessage?.StatusCode}]\n" + $"Parsed Models <{typeof(T).Name}>:\n\t{JsonConvert.SerializeObject(Models)}\n");
8493
}

0 commit comments

Comments
 (0)