forcedotcom / sfdx-plugin-generate

MIT License
73 stars 19 forks source link

Errors thrown via SfdxError are not appearing: sfdx xyz:myplugin:set -u alias -p=xyz #35

Open venkatpolisetti opened 6 years ago

venkatpolisetti commented 6 years ago

Reporting a bug

Errors thrown via SfdxError from the plugin are not appearing when the plugin is invoked via $sfdx xyz:myplugin:set -u myalias -p=xyz

but when invoked through ./bin/run, it would display the error messages.

What is the current behavior?

When run from sfdx, plugin does not display exception message. It simply return without displaying the exception message. $ sfdx xyz:myplugin:set -u venkattemp -o=campaign -profiles="*" Validating flags... $

Where as when I run it from the ./bin in the plugin directory using run, it would work as expected. $ ./bin/run xyz:myplugin:set -u venkattemp -o=campaign -profiles="*" Validating flags... done ERROR running set: --profiles and --filter must be specified when --sobjects is used $

Please mention your Salesforce CLI and OS version. OS: Windows 7 $ sfdx --version sfdx-cli/6.34.0-6fec0d751a (windows-x64) node-v8.9.4

Is there something that I am missing here, a setting or something?

venkatpolisetti commented 6 years ago

Looks like if you are throwing SfdxError after ux.startSpinner, the exception is eaten away by the spinner.

The exception is raised after the startSpinner call in my code.

this.ux.startSpinner('Validating flags');
if (this.flags.datafile && this.flags.profiles == undefined) {
    throw new core.SfdxError('--profiles must be specified when --datafile is used');
}

It started showing the exception message only after I commented startSpinner line.

I still do not understand why it would work with ./bin/run though.

venkatpolisetti commented 5 years ago

Also calling this.ux.stopSpinner() before throwing an exception also worked.