Skip to content

Commit bd99d73

Browse files
Merge pull request #352 from contentstack/fix/DX-10224-bulk-error-visibility
fix(bulk-operations): surface errors on console when console logs are off [DX-10224]
2 parents 7fcf49c + 4156dec commit bd99d73

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,10 +5,13 @@ import {
55
createLogContext,
66
getLogPath,
77
handleAndLogError,
8+
cliErrorHandler,
9+
cliux,
810
FlagInput,
911
getChalk,
1012
loadChalk,
1113
CLIProgressManager,
14+
isConsoleLogEnabled,
1215
} from '@contentstack/cli-utilities';
1316

1417
import config from './config';
@@ -651,13 +654,18 @@ export abstract class BaseBulkCommand extends Command {
651654
* This includes errors during init, run, and other phases
652655
*/
653656
async catch(error: Error): Promise<void> {
654-
// Check if this is a DisplayedError (should be shown to user)
655-
// if (error.name === 'DisplayedError') {
656-
// process.exit(1);
657-
// }
658-
659657
// For other errors, use the CLI utilities error handler
660658
handleAndLogError(error);
659+
660+
// handleAndLogError only reaches the console when the console-log policy is enabled
661+
// (the winston error transport is silenced otherwise), so a failure would leave the
662+
// terminal completely silent when the user has console logs turned off. Print a
663+
// user-facing error line here to fill that gap, guarded so we don't double-print when
664+
// console logs are on and handleAndLogError already emitted the error.
665+
if (!isConsoleLogEnabled()) {
666+
const errorMessage = cliErrorHandler.classifyError(error)?.message || error?.message || 'Unknown error';
667+
cliux.print(`Error: ${errorMessage}`, { color: 'red' });
668+
}
661669
}
662670

663671
abstract run(): Promise<void>;

0 commit comments

Comments
 (0)