/// <summary> /// добавляет ошибку в errorService и все /// </summary> /// <param name="e"></param> protected void ErrorFromCustomException(SomeCustomException e) { if (string.IsNullOrWhiteSpace(e.Message)) { return; } var error = _errorContainer.TryGetError(e.Message); if (error != null) { if (!string.IsNullOrWhiteSpace(e.Body)) { error.Errors.Add(e.Body); } _errorService.AddError(error); return; } if (!string.IsNullOrWhiteSpace(e.Body)) { _errorService.AddError(e.Message, e.Body); } else { _errorService.AddError(ErrorConsts.SomeError, e.Message); } }
public OneError(SomeCustomException exc) { Key = exc.Message; Errors = new List <string>() { exc.Body }; }
public async Task <User> CreateNewAsync(User newUser) { try { if (await _userRepository.UserIsExist(newUser.Email, newUser.Login)) { throw new SomeCustomException("user_already_exist"); } return(await _userRepository.CreateNewAsync(newUser)); } catch (SomeCustomException) { throw; } catch (Exception e) { var newE = new SomeCustomException("can_not_register", "Ошибка при регистрации пользователя", e); throw newE; } }