aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r--Timeline/Controllers/TimelineController.cs3
-rw-r--r--Timeline/Controllers/TokenController.cs1
-rw-r--r--Timeline/Controllers/UserAvatarController.cs1
-rw-r--r--Timeline/Controllers/UserController.cs5
4 files changed, 7 insertions, 3 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs
index 5b894e26..6c7cfa95 100644
--- a/Timeline/Controllers/TimelineController.cs
+++ b/Timeline/Controllers/TimelineController.cs
@@ -13,6 +13,7 @@ using Timeline.Models;
using Timeline.Models.Http;
using Timeline.Models.Validation;
using Timeline.Services;
+using Timeline.Services.Exceptions;
namespace Timeline.Controllers
{
@@ -283,7 +284,7 @@ namespace Timeline.Controllers
var result = _mapper.Map<TimelineInfo>(timeline);
return result;
}
- catch (ConflictException)
+ catch (EntityAlreadyExistException e) when (e.EntityName == EntityNames.Timeline)
{
return BadRequest(ErrorResponse.TimelineController.NameConflict());
}
diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs
index 1fb0b17a..cd67225c 100644
--- a/Timeline/Controllers/TokenController.cs
+++ b/Timeline/Controllers/TokenController.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Timeline.Helpers;
using Timeline.Models.Http;
using Timeline.Services;
+using Timeline.Services.Exceptions;
using static Timeline.Resources.Controllers.TokenController;
namespace Timeline.Controllers
diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs
index 4062837b..b2e2e852 100644
--- a/Timeline/Controllers/UserAvatarController.cs
+++ b/Timeline/Controllers/UserAvatarController.cs
@@ -10,6 +10,7 @@ using Timeline.Helpers;
using Timeline.Models.Http;
using Timeline.Models.Validation;
using Timeline.Services;
+using Timeline.Services.Exceptions;
using static Timeline.Resources.Controllers.UserAvatarController;
namespace Timeline.Controllers
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());
}