mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-25 16:47:55 +01:00
null checks when error handling
This commit is contained in:
parent
8a525aee8a
commit
e71adbd26d
@ -191,17 +191,20 @@ namespace Bit.App.Repositories
|
||||
var statusCode = (int)response.StatusCode;
|
||||
if(statusCode >= 400 && statusCode <= 500)
|
||||
{
|
||||
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ErrorResponse errorResponseModel = null;
|
||||
var errorResponse = JObject.Parse(responseContent);
|
||||
if(errorResponse["ErrorModel"] != null && errorResponse["ErrorModel"]["Message"] != null)
|
||||
|
||||
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
if(!string.IsNullOrWhiteSpace(responseContent))
|
||||
{
|
||||
errorResponseModel = errorResponse["ErrorModel"].ToObject<ErrorResponse>();
|
||||
}
|
||||
else if(errorResponse["Message"] != null)
|
||||
{
|
||||
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
||||
var errorResponse = JObject.Parse(responseContent);
|
||||
if(errorResponse["ErrorModel"] != null && errorResponse["ErrorModel"]["Message"] != null)
|
||||
{
|
||||
errorResponseModel = errorResponse["ErrorModel"].ToObject<ErrorResponse>();
|
||||
}
|
||||
else if(errorResponse["Message"] != null)
|
||||
{
|
||||
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
||||
}
|
||||
}
|
||||
|
||||
if(errorResponseModel != null)
|
||||
|
Loading…
Reference in New Issue
Block a user