Log courier errors to inspector (#29408)

* Log error if courier request fails

* Temporary i18n fix
This commit is contained in:
Tim Roes 2019-01-28 12:13:55 +01:00 committed by GitHub
parent e56342e8ad
commit 0940144f60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,19 +101,26 @@ const CourierRequestHandlerProvider = function () {
);
request.stats(getRequestInspectorStats(requestSearchSource));
const response = await requestSearchSource.fetch();
try {
const response = await requestSearchSource.fetch();
searchSource.lastQuery = queryHash;
searchSource.lastQuery = queryHash;
request
.stats(getResponseInspectorStats(searchSource, response))
.ok({ json: response });
request
.stats(getResponseInspectorStats(searchSource, response))
.ok({ json: response });
searchSource.rawResponse = response;
requestSearchSource.getSearchRequestBody().then(req => {
request.json(req);
});
searchSource.rawResponse = response;
} catch(e) {
// Log any error during request to the inspector
request.error({ json: e });
throw e;
} finally {
// Add the request body no matter if things went fine or not
requestSearchSource.getSearchRequestBody().then(req => {
request.json(req);
});
}
}
let resp = cloneDeep(searchSource.rawResponse);