diff --git a/controller/place.js b/controller/place.js index 5d2703cc..7e49aee3 100644 --- a/controller/place.js +++ b/controller/place.js @@ -55,7 +55,11 @@ function setup( apiConfig, esclient ){ // error handler if( err ){ - req.errors.push( err ); + if (_.isObject(err) && err.message) { + req.errors.push( err.message ); + } else { + req.errors.push( err ); + } } // set response data else { diff --git a/test/unit/controller/place.js b/test/unit/controller/place.js index 5f54ba6d..22622e05 100644 --- a/test/unit/controller/place.js +++ b/test/unit/controller/place.js @@ -137,7 +137,7 @@ module.exports.tests.error_conditions = (test, common) => { const res = {}; const next = () => { - t.deepEqual(req.errors, [nonTimeoutError]); + t.deepEqual(req.errors, [nonTimeoutError.message]); t.deepEqual(req.warnings, []); t.deepEquals(res.data, undefined); t.end(); @@ -209,7 +209,7 @@ module.exports.tests.timeout = function(test, common) { t.ok(infoMesssages.indexOf('request timed out on attempt 2, retrying') !== -1); t.ok(infoMesssages.indexOf('request timed out on attempt 3, retrying') !== -1); - t.deepEqual(req.errors, [timeoutError]); + t.deepEqual(req.errors, [timeoutError.message]); t.deepEqual(res, {}); t.end(); }; @@ -306,7 +306,7 @@ module.exports.tests.timeout = function(test, common) { const next = () => { t.equal(searchServiceCallCount, 1); - t.deepEqual(req.errors, [nonTimeoutError]); + t.deepEqual(req.errors, [nonTimeoutError.message]); t.end(); };