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 | 57c9da7f6bc98fb70e26f5332ffccfd55f7eb69b (patch) | |
tree | 4a2c53d6c5e7f90c88ea287302d01a5d87b730fc /Timeline/Controllers | |
parent | 53b237832d3d967b531a8dc130ebbf2ede173741 (diff) | |
download | timeline-57c9da7f6bc98fb70e26f5332ffccfd55f7eb69b.tar.gz timeline-57c9da7f6bc98fb70e26f5332ffccfd55f7eb69b.tar.bz2 timeline-57c9da7f6bc98fb70e26f5332ffccfd55f7eb69b.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")]
|