diff --git a/src/App/Repositories/BaseApiRepository.cs b/src/App/Repositories/BaseApiRepository.cs index dfc57003b..717094b38 100644 --- a/src/App/Repositories/BaseApiRepository.cs +++ b/src/App/Repositories/BaseApiRepository.cs @@ -73,18 +73,26 @@ namespace Bit.App.Repositories private async Task> ParseErrorsAsync(HttpResponseMessage response) { var errors = new List(); - if(response.StatusCode == System.Net.HttpStatusCode.BadRequest) + var statusCode = (int)response.StatusCode; + if(statusCode >= 400 && statusCode <= 500) { var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var errorResponseModel = JsonConvert.DeserializeObject(responseContent); - foreach(var valError in errorResponseModel.ValidationErrors) + if(errorResponseModel.ValidationErrors.Count > 0) { - foreach(var errorMessage in valError.Value) + foreach(var valError in errorResponseModel.ValidationErrors) { - errors.Add(new ApiError { Message = errorMessage }); + foreach(var errorMessage in valError.Value) + { + errors.Add(new ApiError { Message = errorMessage }); + } } } + else + { + errors.Add(new ApiError { Message = errorResponseModel.Message }); + } } return errors;