diff --git a/src/cli/facade/publish.js b/src/cli/facade/publish.js index af74305b1..93b723d59 100644 --- a/src/cli/facade/publish.js +++ b/src/cli/facade/publish.js @@ -113,6 +113,11 @@ module.exports = function(dependencies) { logger.err(errorMessage); return cb(errorMessage); } else { + if (_.isObject(err)) { + try { + err = JSON.stringify(err); + } catch (er) {} + } errorMessage = format(strings.errors.cli.PUBLISHING_FAIL, err); logger.err(errorMessage); return cb(errorMessage); diff --git a/test/unit/cli-facade-publish.js b/test/unit/cli-facade-publish.js index 86eee1116..a8ff22b9a 100644 --- a/test/unit/cli-facade-publish.js +++ b/test/unit/cli-facade-publish.js @@ -182,6 +182,25 @@ describe('cli : facade : publish', () => { }); }); + describe('when a generic error happens from the api', () => { + beforeEach(done => { + sinon + .stub(registry, 'putComponent') + .yields({ IgotAnError: true }); + execute(done); + }); + + afterEach(() => { + registry.putComponent.restore(); + }); + + it('should show an error', () => { + expect(logSpy.err.args[0][0]).to.include( + 'An error happened when publishing the component: {"IgotAnError":true}' + ); + }); + }); + describe('when using an old cli', () => { beforeEach(done => { sinon.stub(registry, 'putComponent').yields({