From fcc484c37a6c760a51ce84bea632cc7667cb607b Mon Sep 17 00:00:00 2001 From: Steve Hobbs Date: Mon, 23 Mar 2020 21:56:26 +0000 Subject: [PATCH] Made error codes + details more generic * Removed check for `blocked_users` code * Changed property name on error object from `blockUser` to `errorDetails` --- src/helper/response-handler.js | 9 +++------ test/helper/response-handler.test.js | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/helper/response-handler.js b/src/helper/response-handler.js index fb558e41..15e754c3 100644 --- a/src/helper/response-handler.js +++ b/src/helper/response-handler.js @@ -54,17 +54,14 @@ function wrapCallback(cb, options) { err.details || err.err || null; + if (options.forceLegacyError) { errObj.error = errObj.code; errObj.error_description = errObj.description; } - if ( - errObj.code === 'blocked_user' && - err.error_codes && - err.error_details - ) { - errObj.blockedUser = { + if (err.error_codes && err.error_details) { + errObj.errorDetails = { codes: err.error_codes, details: err.error_details }; diff --git a/test/helper/response-handler.test.js b/test/helper/response-handler.test.js index 5f354198..499510ee 100644 --- a/test/helper/response-handler.test.js +++ b/test/helper/response-handler.test.js @@ -150,7 +150,7 @@ describe('helpers responseHandler', function() { })(assert_err, null); }); - it('should return normalized block codes', function(done) { + it('should return normalized error codes and details', function(done) { var assert_err = {}; assert_err.response = {}; assert_err.response.body = { @@ -174,7 +174,7 @@ describe('helpers responseHandler', function() { original: assert_err, code: 'blocked_user', description: 'Blocked user.', - blockedUser: { + errorDetails: { codes: ['reason-1', 'reason-2'], details: { 'reason-1': {