diff options
author | crupest <crupest@outlook.com> | 2020-01-23 20:51:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-23 20:51:02 +0800 |
commit | c72996ff9854aededc4ecfab92ef5d42167edd86 (patch) | |
tree | 1e722a0618cdb0fe3f784a0c4100727a5b2b3ece /Timeline/Controllers/UserController.cs | |
parent | 4aadb05cd5718c7d16bf432c96e23ae4e7db4783 (diff) | |
download | timeline-c72996ff9854aededc4ecfab92ef5d42167edd86.tar.gz timeline-c72996ff9854aededc4ecfab92ef5d42167edd86.tar.bz2 timeline-c72996ff9854aededc4ecfab92ef5d42167edd86.zip |
...
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r-- | Timeline/Controllers/UserController.cs | 11 |
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]
|