From 76148b27f7501bac061992136852be4303370c8d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 1 Jun 2021 01:36:53 +0200 Subject: refactor API errors to standard error format --- server/controllers/api/custom-page.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'server/controllers/api/custom-page.ts') diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index 3c47f7b9a..c19f03c56 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts @@ -27,7 +27,12 @@ export { async function getInstanceHomepage (req: express.Request, res: express.Response) { const page = await ActorCustomPageModel.loadInstanceHomepage() - if (!page) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + if (!page) { + return res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'Instance homepage could not be found' + }) + } return res.json(page.toFormattedJSON()) } @@ -38,5 +43,5 @@ async function updateInstanceHomepage (req: express.Request, res: express.Respon await ActorCustomPageModel.updateInstanceHomepage(content) ServerConfigManager.Instance.updateHomepageState(content) - return res.sendStatus(HttpStatusCode.NO_CONTENT_204) + return res.status(HttpStatusCode.NO_CONTENT_204).end() } -- cgit v1.2.3