aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/UserController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-01-23 20:51:02 +0800
committercrupest <crupest@outlook.com>2020-01-23 20:51:02 +0800
commit42215e7d28d6144e5a19f77ddc060c42b7afdad5 (patch)
tree1e722a0618cdb0fe3f784a0c4100727a5b2b3ece /Timeline/Controllers/UserController.cs
parent747bf829351c30069647a44f98ac19f1a214370f (diff)
downloadtimeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.tar.gz
timeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.tar.bz2
timeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.zip
...
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r--Timeline/Controllers/UserController.cs11
1 files changed, 7 insertions, 4 deletions
diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs
index 65ee3a0f..5f1b7bd7 100644
--- a/Timeline/Controllers/UserController.cs
+++ b/Timeline/Controllers/UserController.cs
@@ -35,13 +35,16 @@ namespace Timeline.Controllers
[HttpGet("users/{username}"), AdminAuthorize]
public async Task<ActionResult<User>> Get([FromRoute][Username] string username)
{
- var user = await _userService.GetUserByUsername(username);
- if (user == null)
+ try
+ {
+ var user = await _userService.GetUserByUsername(username);
+ return Ok(user);
+ }
+ catch (UserNotExistException e)
{
- _logger.LogInformation(Log.Format(LogGetUserNotExist, ("Username", username)));
+ _logger.LogInformation(e, Log.Format(LogGetUserNotExist, ("Username", username)));
return NotFound(ErrorResponse.UserCommon.NotExist());
}
- return Ok(user);
}
[HttpPut("users/{username}"), AdminAuthorize]