From 57c9da7f6bc98fb70e26f5332ffccfd55f7eb69b Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 11 Mar 2020 18:38:22 +0800 Subject: ... --- Timeline/Controllers/TimelineController.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Timeline/Controllers') 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")] -- cgit v1.2.3