diff --git a/packages/contentstack-bulk-operations/src/base-bulk-command.ts b/packages/contentstack-bulk-operations/src/base-bulk-command.ts index ecef6bbd2..b67f9862d 100644 --- a/packages/contentstack-bulk-operations/src/base-bulk-command.ts +++ b/packages/contentstack-bulk-operations/src/base-bulk-command.ts @@ -5,10 +5,13 @@ import { createLogContext, getLogPath, handleAndLogError, + cliErrorHandler, + cliux, FlagInput, getChalk, loadChalk, CLIProgressManager, + isConsoleLogEnabled, } from '@contentstack/cli-utilities'; import config from './config'; @@ -651,13 +654,18 @@ export abstract class BaseBulkCommand extends Command { * This includes errors during init, run, and other phases */ async catch(error: Error): Promise { - // Check if this is a DisplayedError (should be shown to user) - // if (error.name === 'DisplayedError') { - // process.exit(1); - // } - // For other errors, use the CLI utilities error handler handleAndLogError(error); + + // handleAndLogError only reaches the console when the console-log policy is enabled + // (the winston error transport is silenced otherwise), so a failure would leave the + // terminal completely silent when the user has console logs turned off. Print a + // user-facing error line here to fill that gap, guarded so we don't double-print when + // console logs are on and handleAndLogError already emitted the error. + if (!isConsoleLogEnabled()) { + const errorMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error'; + cliux.print(`Error: ${errorMessage}`, { color: 'red' }); + } } abstract run(): Promise;