aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/UserController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-13 00:28:35 +0800
committercrupest <crupest@outlook.com>2020-06-13 00:28:35 +0800
commiteba8e9698c09b805d8ac2a8f58db93b947ac29e3 (patch)
treec3bf0aef9d80c19e9a71e9e9aaab16b8364db15b /Timeline/Controllers/UserController.cs
parentcc62df19e5f8aa216660915f46ff290c8eeab1d0 (diff)
downloadtimeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.tar.gz
timeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.tar.bz2
timeline-eba8e9698c09b805d8ac2a8f58db93b947ac29e3.zip
refactor(back): Fix #100 .
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r--Timeline/Controllers/UserController.cs5
1 files changed, 3 insertions, 2 deletions
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<User>(body));
return Ok(ConvertToUserInfo(user));
}
- catch (ConflictException)
+ catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.User)
{
return BadRequest(ErrorResponse.UserController.UsernameConflict());
}