fix: show 404 page if /api/v2/meta/page/{page} can't find a file
This commit is contained in:
		
							parent
							
								
									0c6e3bf38f
								
							
						
					
					
						commit
						c8e4078b35
					
				
					 6 changed files with 17 additions and 9 deletions
				
			
		|  | @ -58,8 +58,15 @@ public partial class MetaController(Config config) : ApiControllerBase | |||
|         } | ||||
| 
 | ||||
|         string path = Path.Join(Directory.GetCurrentDirectory(), "static-pages", $"{page}.md"); | ||||
|         string text = await System.IO.File.ReadAllTextAsync(path, ct); | ||||
|         return Ok(text); | ||||
|         try | ||||
|         { | ||||
|             string text = await System.IO.File.ReadAllTextAsync(path, ct); | ||||
|             return Ok(text); | ||||
|         } | ||||
|         catch (FileNotFoundException) | ||||
|         { | ||||
|             throw new ApiError.NotFound("Page not found", code: ErrorCode.PageNotFound); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     [HttpGet("/api/v2/coffee")] | ||||
|  |  | |||
|  | @ -164,6 +164,7 @@ public enum ErrorCode | |||
|     GenericApiError, | ||||
|     UserNotFound, | ||||
|     MemberNotFound, | ||||
|     PageNotFound, | ||||
|     AccountAlreadyLinked, | ||||
|     LastAuthMethod, | ||||
|     InvalidReportTarget, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue