<commit_before>'use strict';


const getErrorMessage = function ({
  error: {
    type,
    description,
    protocol,
    interface: interf,
    action_path,
    command,
    details,
  },
}) {
  const stack = getStack(description, details);
  const message = [
    protocol,
    interf,
    action_path,
    command,
    stack,
  ].filter(val => val)
    .join(' ');
  const fullMessage = message ? `${type} - ${message}` : type;

  return fullMessage;
};

const getStack = function (description, details = '') {
  const stack = details.indexOf(description) !== -1
    ? details
    : `${description}\n${details}`;

  const dirPrefixRegExp = new RegExp(global.apiEngineDirName, 'g');
  const trimmedStack = stack.replace(dirPrefixRegExp, '');

  const finalStack = trimmedStack ? `\n${trimmedStack}` : '';
  return finalStack;
};


module.exports = {
  getErrorMessage,
};<commit_msg>Better stack printing<commit_after>'use strict';


const getErrorMessage = function ({
  error: {
    type,
    description,
    protocol,
    interface: interf,
    action_path,
    command,
    details,
  },
}) {
  const stack = getStack(description, details);

  const message = [
    protocol,
    interf,
    action_path,
    command,
  ].filter(val => val)
    .join(' ');

  const messageStack = message && stack
    ? `${message}\n${stack}`
    : message ? message : stack;
  const fullMessage = messageStack ? `${type} - ${messageStack}` : type;

  return fullMessage;
};

const getStack = function (description, details = '') {
  const stack = details.indexOf(description) !== -1
    ? details
    : `${description}\n${details}`;

  const dirPrefixRegExp = new RegExp(global.apiEngineDirName, 'g');
  const trimmedStack = stack.replace(dirPrefixRegExp, '');

  return trimmedStack;
};


module.exports = {
  getErrorMessage,
};
{'fraction_non_alphanumeric': 0.1437191442676906, 'fraction_numerical': 0.0010970927043335162, 'mean_word_length': 3.3846153846153846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2808404', 'n_tokens_mistral': 569, 'n_tokens_neox': 562, 'n_words': 131}