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/search.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'server/controllers/api/search.ts') diff --git a/server/controllers/api/search.ts b/server/controllers/api/search.ts index f0cdf3a89..77e3a024d 100644 --- a/server/controllers/api/search.ts +++ b/server/controllers/api/search.ts @@ -102,7 +102,10 @@ async function searchVideoChannelsIndex (query: VideoChannelsSearchQuery, res: e } catch (err) { logger.warn('Cannot use search index to make video channels search.', { err }) - return res.sendStatus(HttpStatusCode.INTERNAL_SERVER_ERROR_500) + return res.fail({ + status: HttpStatusCode.INTERNAL_SERVER_ERROR_500, + message: 'Cannot use search index to make video channels search' + }) } } @@ -202,7 +205,10 @@ async function searchVideosIndex (query: VideosSearchQuery, res: express.Respons } catch (err) { logger.warn('Cannot use search index to make video search.', { err }) - return res.sendStatus(HttpStatusCode.INTERNAL_SERVER_ERROR_500) + return res.fail({ + status: HttpStatusCode.INTERNAL_SERVER_ERROR_500, + message: 'Cannot use search index to make video search' + }) } } -- cgit v1.2.3