packages/ant-util-yargs/lib/yargsHelper.js
function handleErrorMessage (msg, err, command, exitProcess) {
  setErrorHandled();
  console.error(`Fatal => ${msg}`);
  if (err) {
    console.error();
    if (isVerboseMode()) {
      console.error('Error stack:');
      console.error(err.stack);
    } else {
      console.error('For getting the error stack, use --verbose option');
    }
  }
  console.error();
  console.error('For getting help:');
  console.error(
    `${getCliFileName()} --help ${command ? command : '[command]'}`
  );
  if (!err && msg) {
    err = new Error(msg);
  }
  if (!exitProcess) {
    return Analytics.trackError(err).then(() => process.exit(1));
  }
  process.exit(1);
}
function handleErrorMessage (msg, err, command, exitProcess) {
  setErrorHandled();
  console.error(`Fatal => ${msg}`);
  if (err) {
    console.error();
    if (isVerboseMode()) {
      console.error('Error stack:');
      console.error(err.stack);
    } else {
      console.error('For getting the error stack, use --verbose option');
    }
  }
  console.error();
  console.error('For getting help:');
  console.error(
    `${getCliFileName()} --help ${command ? command : '[command]'}`
  );
  if (!err && msg) {
    err = new Error(msg);
  }
  if (!exitProcess) {
    return Analytics.trackError(err).then(() => process.exit(1));
  }
  process.exit(1);
}
function handleErrorMessage ( msg , err , command , exitProcess ) { setErrorHandled ( ) ; console . error ( ` ${ msg } ` ) ; if ( err ) { console . error ( ) ; if ( isVerboseMode ( ) ) { console . error ( 'Error stack:' ) ; console . error ( err . stack ) ; } else { console . error ( 'For getting the error stack, use --verbose option' ) ; } } console . error ( ) ; console . error ( 'For getting help:' ) ; console . error ( ` ${ getCliFileName ( ) } ${ command ? command : '[command]' } ` ) ; if ( ! err && msg ) { err = new Error ( msg ) ; } if ( ! exitProcess ) { return Analytics . trackError ( err ) . then ( ( ) => process . exit ( 1 ) ) ; } process . exit ( 1 ) ; }
Helper function that can be used to handle and print error messages occurred
during Yargs parsing and execution.
@param {String} msg The error message.
@param {Error} err The error that generated the problem.
@param {String} command The command that failed.
@param {Boolean} exitProcess Flag indicating it should invoke process.exit
after logging error messages.
@returns {Promise} The error tracking request promise
Helper function that can be used to handle and print error messages occurred during Yargs parsing and execution .