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 | 42215e7d28d6144e5a19f77ddc060c42b7afdad5 (patch) | |
tree | 1e722a0618cdb0fe3f784a0c4100727a5b2b3ece /Timeline/Controllers/UserController.cs | |
parent | 747bf829351c30069647a44f98ac19f1a214370f (diff) | |
download | timeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.tar.gz timeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.tar.bz2 timeline-42215e7d28d6144e5a19f77ddc060c42b7afdad5.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]
|