Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meaningful error shown when publish fails due to a generic API error #699

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cli/facade/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions test/unit/cli-facade-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down