diff --git a/lib/img-workers.js b/lib/img-workers.js index 982ab08..94fdbe1 100644 --- a/lib/img-workers.js +++ b/lib/img-workers.js @@ -41,7 +41,7 @@ exports.upload = function upload(id, payload, headers) { } if (res.statusCode >= 400 || (body && body.error) || nestedError) { - logger.error('upload.worker.error', body); + logger.error('upload.worker.error', nestedError || body); reject(AppError.processingError(body)); return; } diff --git a/test/api.js b/test/api.js index 28d332d..03444ec 100644 --- a/test/api.js +++ b/test/api.js @@ -735,12 +735,12 @@ describe('/avatar', function() { user: USERID, scope: ['profile:avatar:write'] }); - mock.workerFailure('post', imageData.length); + mock.workerFailure('post', imageData.length, [ { error: 'wibble' } ]); mock.log('img_workers', function(rec) { if (rec.levelname === 'ERROR') { assert.equal( rec.message, - 'upload.worker.error unexpected server error' + 'upload.worker.error wibble' ); return true; } diff --git a/test/lib/mock.js b/test/lib/mock.js index 0892224..2f4e490 100644 --- a/test/lib/mock.js +++ b/test/lib/mock.js @@ -174,7 +174,7 @@ module.exports = function mock(options) { .reply(200, body); }, - workerFailure: function workerFailure(action, bytes) { + workerFailure: function workerFailure(action, bytes, response) { if (action !== 'post' && action !== 'delete') { throw new Error('failure must be post or delete'); } @@ -191,7 +191,7 @@ module.exports = function mock(options) { }) .filteringPath(/^\/a\/[0-9a-f]{32}$/g, '/a/' + MOCK_ID) [action]('/a/' + MOCK_ID) // eslint-disable-line no-unexpected-multiline - .reply(500, 'unexpected server error'); + .reply(500, response || 'unexpected server error'); },