Sean Hayes
04/23/2022, 9:34 PMnotifyOfftrueSean Hayes
04/23/2022, 11:40 PMSean Hayes
04/23/2022, 11:49 PMthrow createCSVUserError({
name: 'CSV_VALIDATION_ERROR',
message: 'You can only use XXX Account for this transaction!',
notifyOff: true
});
/**
 * Create an Error Object which prints only the Error Message when toString() is called.
 * @param {Object} errorOptions
 * @return {Object} error
 */
function createCSVUserError(errorOptions) {
  const csvUserError = error.create(errorOptions);
  if (errorOptions.notifyOff) {
    // log the original error
    log.error({title: 'Returning CSV User Error', details: csvUserError});
  }
  // print only the error message to the csv error line.
  csvUserError.toString = () => {
    return csvUserError.message;
  };
  return csvUserError;
}