mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 16:21:55 +03:00
null checks when error handling
This commit is contained in:
parent
8a525aee8a
commit
e71adbd26d
1 changed files with 12 additions and 9 deletions
|
@ -191,17 +191,20 @@ namespace Bit.App.Repositories
|
||||||
var statusCode = (int)response.StatusCode;
|
var statusCode = (int)response.StatusCode;
|
||||||
if(statusCode >= 400 && statusCode <= 500)
|
if(statusCode >= 400 && statusCode <= 500)
|
||||||
{
|
{
|
||||||
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
||||||
|
|
||||||
ErrorResponse errorResponseModel = null;
|
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>();
|
var errorResponse = JObject.Parse(responseContent);
|
||||||
}
|
if(errorResponse["ErrorModel"] != null && errorResponse["ErrorModel"]["Message"] != null)
|
||||||
else if(errorResponse["Message"] != null)
|
{
|
||||||
{
|
errorResponseModel = errorResponse["ErrorModel"].ToObject<ErrorResponse>();
|
||||||
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
}
|
||||||
|
else if(errorResponse["Message"] != null)
|
||||||
|
{
|
||||||
|
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(errorResponseModel != null)
|
if(errorResponseModel != null)
|
||||||
|
|
Loading…
Reference in a new issue