Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/contentstack-bulk-operations/src/base-bulk-command.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,10 +5,13 @@ import {
createLogContext,
getLogPath,
handleAndLogError,
cliErrorHandler,
cliux,
FlagInput,
getChalk,
loadChalk,
CLIProgressManager,
isConsoleLogEnabled,
} from '@contentstack/cli-utilities';

import config from './config';
Expand DownExpand Up@@ -651,13 +654,18 @@ export abstract class BaseBulkCommand extends Command {
* This includes errors during init, run, and other phases
*/
async catch(error: Error): Promise<void> {
// 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<void>;
Expand Down
Loading