Skip to content

Commit cc9036c

Browse files
fix(bulk-operations): surface errors on console when console logs are off
Bulk command failures were silently swallowed when log.showConsoleLogs was disabled — handleAndLogError only reaches the console through the winston error transport, which is silenced in that mode, so the terminal showed nothing on failure (e.g. an invalid stack API key). Print a user-facing error line in BaseBulkCommand.catch() when console logs are off, reusing cliErrorHandler.classifyError so the message matches the friendly text written to the log file. Guarded to avoid double-printing when console logs are on. Ref: DX-10224 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d1aaa7e commit cc9036c

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎packages/contentstack-bulk-operations/src/base-bulk-command.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
createLogContext,
66
getLogPath,
77
handleAndLogError,
8+
cliErrorHandler,
9+
cliux,
810
FlagInput,
911
getChalk,
1012
loadChalk,
@@ -663,13 +665,19 @@ export abstract class BaseBulkCommand extends Command {
663665
* This includes errors during init, run, and other phases
664666
*/
665667
async catch(error: Error): Promise<void> {
666-
// Check if this is a DisplayedError (should be shown to user)
667-
// if (error.name === 'DisplayedError') {
668-
// process.exit(1);
669-
// }
670-
671668
// For other errors, use the CLI utilities error handler
672669
handleAndLogError(error);
670+
671+
// handleAndLogError only reaches the console when log.showConsoleLogs is enabled
672+
// (the winston error transport is silenced otherwise), so a failure would leave the
673+
// terminal completely silent when the user has console logs turned off. Print a
674+
// user-facing error line here to fill that gap, guarded so we don't double-print when
675+
// console logs are on and handleAndLogError already emitted the error.
676+
const showConsoleLogs = Boolean(configHandler.get('log')?.showConsoleLogs);
677+
if (!showConsoleLogs) {
678+
const friendlyMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error';
679+
cliux.print(`Error: ${friendlyMessage}`, { color: 'red' });
680+
}
673681
}
674682

675683
abstract run(): Promise<void>;

0 commit comments

Comments
 (0)