From 9303969d7b386be5bcbb571b3d6ac513a79cd5f0 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Fri, 26 Jan 2018 15:16:37 +0000 Subject: [PATCH] Bail out if history API request fails --- .../coffee/Features/History/HistoryController.coffee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/History/HistoryController.coffee b/services/web/app/coffee/Features/History/HistoryController.coffee index f8f1578bd5..b8f3f4dcfb 100644 --- a/services/web/app/coffee/Features/History/HistoryController.coffee +++ b/services/web/app/coffee/Features/History/HistoryController.coffee @@ -46,9 +46,14 @@ module.exports = HistoryController = "X-User-Id": user_id }, (error, response, body) -> return next(error) if error? - HistoryManager.injectUserDetails body, (error, data) -> - return next(error) if error? - res.json data + if 200 <= res.statusCode < 300 + HistoryManager.injectUserDetails body, (error, data) -> + return next(error) if error? + res.json data + else + error = new Error("history api responded with non-success code: #{res.statusCode}") + logger.error err: error, user_id: user_id, "error proxying request to history api" + next(error) buildHistoryServiceUrl: (useProjectHistory) -> # choose a history service, either document-level (trackchanges)