From d6e9ae92a782f747752d9e26504dc2f27e723f04 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 13 Jun 2020 00:28:35 +0800 Subject: refactor(back): Fix #100 . --- Timeline/Controllers/UserController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Timeline/Controllers/UserController.cs') diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index 0bc8bcda..c8c1e610 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -11,6 +11,7 @@ using Timeline.Models; using Timeline.Models.Http; using Timeline.Models.Validation; using Timeline.Services; +using Timeline.Services.Exceptions; using static Timeline.Resources.Controllers.UserController; using static Timeline.Resources.Messages; @@ -70,7 +71,7 @@ namespace Timeline.Controllers _logger.LogInformation(e, Log.Format(LogPatchUserNotExist, ("Username", username))); return NotFound(ErrorResponse.UserCommon.NotExist()); } - catch (ConflictException) + catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.User) { return BadRequest(ErrorResponse.UserController.UsernameConflict()); } @@ -116,7 +117,7 @@ namespace Timeline.Controllers var user = await _userService.CreateUser(_mapper.Map(body)); return Ok(ConvertToUserInfo(user)); } - catch (ConflictException) + catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.User) { return BadRequest(ErrorResponse.UserController.UsernameConflict()); } -- cgit v1.2.3