diff --git a/src/management/JobsManager.js b/src/management/JobsManager.js index f52a63893..fb26918f5 100644 --- a/src/management/JobsManager.js +++ b/src/management/JobsManager.js @@ -164,7 +164,7 @@ JobsManager.prototype.importUsers = function(data, cb) { var type = (res.statusCode / 100) | 0; var isErrorResponse = 4 === type || 5 === type; if (isErrorResponse) { - var error = new Error('cannot ' + method + url + ' (' + res.statusCode + ')'); + var error = new Error('cannot ' + method + ' ' + url + ' (' + res.statusCode + ')'); error.status = res.statusCode; error.method = method; error.text = res.text; diff --git a/test/management/jobs.tests.js b/test/management/jobs.tests.js index b1f4d3234..432f3d203 100644 --- a/test/management/jobs.tests.js +++ b/test/management/jobs.tests.js @@ -175,7 +175,7 @@ describe('JobsManager', function() { .catch(done.bind(null, null)); }); - it('should pass any errors to the promise catch handler', function(done) { + it('should pass HTTP errors to the promise catch handler', function(done) { nock.cleanAll(); var request = nock(API_URL) @@ -183,7 +183,9 @@ describe('JobsManager', function() { .reply(500); this.jobs.importUsers(data).catch(function(err) { - expect(err).to.exist; + expect(err.message).to.equal( + 'cannot POST https://tenant.auth0.com/jobs/users-imports (500)' + ); done(); }); });