From c365283e3469e0ad98cd206e7daa2a1a40b31a12 Mon Sep 17 00:00:00 2001 From: Viktor Somodi Date: Tue, 11 Apr 2017 13:30:14 +0200 Subject: [PATCH] feat(wrapper): log request informations in errors --- wrapper.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wrapper.js b/wrapper.js index 63e1a8e..1d71b9f 100644 --- a/wrapper.js +++ b/wrapper.js @@ -54,12 +54,12 @@ RequestWrapper.prototype = { request[method](reqOptions, function(err, response) { if (err) { - logger.error('fatal_error', err.message); + logger.error('fatal_error', err.message, this._getLogParameters()); return reject(new SuiteRequestError(err.message, 500)); } if (!this.requestOptions.allowEmptyResponse && !response.body) { - logger.error('server_error', 'empty response data'); + logger.error('server_error', 'empty response data', this._getLogParameters()); return reject(new SuiteRequestError('Empty http response', 500, response.statusMessage)); } @@ -67,15 +67,15 @@ RequestWrapper.prototype = { try { response.body = JSON.parse(response.body); } catch (ex) { - logger.error('fatal_error', ex); + logger.error('fatal_error', ex, this._getLogParameters()); return reject(new SuiteRequestError(ex.message, 500)); } } if (response.statusCode >= 400) { - logger.error('server_error', response.body.replyText, { + logger.error('server_error', response.body.replyText, this._getLogParameters({ code: response.statusCode - }); + })); return reject(new SuiteRequestError( 'Error in http response (status: ' + response.statusCode + ')', response.statusCode,