Skip to content

Commit

Permalink
Made error codes + details more generic
Browse files Browse the repository at this point in the history
* Removed check for `blocked_users` code
* Changed property name on error object from `blockUser` to
`errorDetails`
  • Loading branch information
Steve Hobbs committed Mar 23, 2020
1 parent 1cb995b commit fcc484c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/helper/response-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
4 changes: 2 additions & 2 deletions test/helper/response-handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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': {
Expand Down

0 comments on commit fcc484c

Please sign in to comment.