Bail out if history API request fails

This commit is contained in:
Michael Walker 2018-02-02 09:43:57 +00:00
parent 9955fd570c
commit e886217b85

View file

@ -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 <= response.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: #{response.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)