mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 08:12:26 +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,9 +191,11 @@ 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 responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||||
|
if(!string.IsNullOrWhiteSpace(responseContent))
|
||||||
|
{
|
||||||
var errorResponse = JObject.Parse(responseContent);
|
var errorResponse = JObject.Parse(responseContent);
|
||||||
if(errorResponse["ErrorModel"] != null && errorResponse["ErrorModel"]["Message"] != null)
|
if(errorResponse["ErrorModel"] != null && errorResponse["ErrorModel"]["Message"] != null)
|
||||||
{
|
{
|
||||||
|
@ -203,6 +205,7 @@ namespace Bit.App.Repositories
|
||||||
{
|
{
|
||||||
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
errorResponseModel = errorResponse.ToObject<ErrorResponse>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(errorResponseModel != null)
|
if(errorResponseModel != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue