Skip to content

Commit b63ebae

Browse files
fix(bulk-operations): display taxonomy error messages in progress-manager mode
In progress-manager mode (log.showConsoleLogs=false) the logger suppresses errors on the console, so bulk-taxonomies failures — including setup errors thrown in init() like "We can't find that Stack" — left a blank screen. Add a surfaceError helper wired into run()'s catch (operation-phase errors) and a catch() override (init-phase errors that never reach run()). It prints the message via cliux only when console logging is suppressed, and skips DisplayedError to avoid duplicating messages validators already print. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8c675f9 commit b63ebae

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-taxonomies.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Command } from '@contentstack/cli-command';
2-
import { flags, log, createLogContext, handleAndLogError, loadChalk } from '@contentstack/cli-utilities';
2+
import { flags, log, createLogContext, handleAndLogError, loadChalk, configHandler, cliux } from '@contentstack/cli-utilities';
33

44
import messages, { $t } from '../../../messages';
55
import { BaseBulkCommand } from '../../../base-bulk-command';
@@ -116,11 +116,39 @@ export default class BulkTaxonomies extends BaseBulkCommand {
116116
this.printOperationSummary(result);
117117
} catch (error) {
118118
handleAndLogError(error);
119+
this.surfaceError(error);
119120
} finally {
120121
await this.finally(undefined);
121122
}
122123
}
123124

125+
/**
126+
* Taxonomy stack/env validation errors are thrown in init() (setupStack) and reach oclif's
127+
* catch() rather than run(). In progress-manager mode the console logger is suppressed
128+
* (log.showConsoleLogs === false), so handleAndLogError writes only to the log file and the
129+
* user sees nothing. Surface the message on the console here, then delegate to the base handler.
130+
*/
131+
async catch(error: Error): Promise<void> {
132+
await super.catch(error);
133+
this.surfaceError(error);
134+
}
135+
136+
/**
137+
* Print an error to the console when progress-manager mode has suppressed console logging.
138+
* No-op when console logging is enabled (the logger already printed it) or for DisplayedError
139+
* (validators print those directly, so printing again would duplicate them).
140+
*/
141+
private surfaceError(error: unknown): void {
142+
if (error instanceof Error && error.name === 'DisplayedError') {
143+
return;
144+
}
145+
const showConsoleLogs = configHandler.get('log')?.showConsoleLogs;
146+
if (!showConsoleLogs) {
147+
const message = error instanceof Error ? error.message : String(error);
148+
cliux.print(`Error: ${message}`);
149+
}
150+
}
151+
124152
protected async fetchTaxonomies(): Promise<TaxonomyPublishItem[]> {
125153
const parsed = this.parsedFlags;
126154
const itemsStr = String(parsed.taxonomies || '').trim();

0 commit comments

Comments
 (0)