diff options
author | crupest <crupest@outlook.com> | 2020-01-19 22:45:43 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-19 22:45:43 +0800 |
commit | 40eea04e1ec9b71c5215e9dce5a6963ea60cafaa (patch) | |
tree | 1fa3969a53138becb76a7eef7bafdafc7046c12c /Timeline | |
parent | 4ec507df6251bc1dae5204fdc6aaf14ddbb268f6 (diff) | |
download | timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.tar.gz timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.tar.bz2 timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.zip |
Basically finish refactor of error codes.
Diffstat (limited to 'Timeline')
-rw-r--r-- | Timeline/Controllers/PersonalTimelineController.cs | 3 | ||||
-rw-r--r-- | Timeline/Controllers/TokenController.cs | 4 | ||||
-rw-r--r-- | Timeline/Controllers/UserAvatarController.cs | 4 |
3 files changed, 5 insertions, 6 deletions
diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index e1e3aba0..2c70fad1 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
-using System.Globalization;
using System.Threading.Tasks;
using Timeline.Auth;
using Timeline.Filters;
@@ -134,7 +133,7 @@ namespace Timeline.Controllers }
else if (e.InnerException is UserNotExistException)
{
- return BadRequest(ErrorResponse.Common.CustomMessage_InvalidModel(
+ return BadRequest(ErrorResponse.UserCommon.CustomMessage_NotExist(
TimelineController_ChangeMember_UserNotExist, e.Index, e.Operation));
}
diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index c360a109..67001e87 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -99,7 +99,7 @@ namespace Timeline.Controllers if (e.ErrorCode == JwtVerifyException.ErrorCodes.Expired)
{
var innerException = e.InnerException as SecurityTokenExpiredException;
- LogFailure(LogVerifyExpire, e, ("Expires", innerException.Expires),
+ LogFailure(LogVerifyExpire, e, ("Expires", innerException?.Expires),
("Current Time", _clock.GetCurrentTime()));
return BadRequest(ErrorResponse.TokenController.Verify_TimeExpired());
}
@@ -107,7 +107,7 @@ namespace Timeline.Controllers {
var innerException = e.InnerException as JwtBadVersionException;
LogFailure(LogVerifyOldVersion, e,
- ("Token Version", innerException.TokenVersion),
+ ("Token Version", innerException?.TokenVersion),
("Required Version", innerException?.RequiredVersion));
return BadRequest(ErrorResponse.TokenController.Verify_OldVersion());
}
diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index b4a6d8fd..62f1d78c 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -66,7 +66,7 @@ namespace Timeline.Controllers catch (UserNotExistException e)
{
_logger.LogInformation(e, Log.Format(LogGetUserNotExist, ("Username", username)));
- return NotFound(ErrorResponse.UserController.ChangePassword_BadOldPassword());
+ return NotFound(ErrorResponse.UserCommon.NotExist());
}
}
@@ -112,7 +112,7 @@ namespace Timeline.Controllers catch (UserNotExistException e)
{
_logger.LogInformation(e, Log.Format(LogPutUserNotExist, ("Username", username)));
- return BadRequest(ErrorResponse.UserController.ChangePassword_BadOldPassword());
+ return BadRequest(ErrorResponse.UserCommon.NotExist());
}
catch (AvatarFormatException e)
{
|