diff options
author | crupest <crupest@outlook.com> | 2020-03-11 18:38:22 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-11 18:38:22 +0800 |
commit | 2945aaf506a351cda89bc552aa1bcb734055438d (patch) | |
tree | 4a2c53d6c5e7f90c88ea287302d01a5d87b730fc /Timeline/Controllers | |
parent | 27ed44bb8c618e4b30de5cec44bbb47be8084539 (diff) | |
download | timeline-2945aaf506a351cda89bc552aa1bcb734055438d.tar.gz timeline-2945aaf506a351cda89bc552aa1bcb734055438d.tar.bz2 timeline-2945aaf506a351cda89bc552aa1bcb734055438d.zip |
...
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 0628937d..6e5438c4 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -123,8 +123,19 @@ namespace Timeline.Controllers return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
}
- var data = await _service.GetPostData(name, id);
- return File(data.Data, data.Type, data.LastModified, new EntityTagHeaderValue(data.ETag));
+ try
+ {
+ var data = await _service.GetPostData(name, id);
+ return File(data.Data, data.Type, data.LastModified, new EntityTagHeaderValue(data.ETag));
+ }
+ catch (TimelinePostNotExistException)
+ {
+ return NotFound(ErrorResponse.TimelineController.PostNotExist());
+ }
+ catch (InvalidOperationException)
+ {
+ return BadRequest(ErrorResponse.TimelineController.PostNoData());
+ }
}
[HttpPost("timelines/{name}/posts")]
|