{"size": 537, "ext": "js", "max_stars_repo_path": "server/utils/functionsWrapper.js", "max_stars_repo_name": "duvalale/Gladys", "max_stars_repo_stars_event_min_datetime": "2015-01-18T23:39:32.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-07T07:38:57.000Z", "max_issues_repo_path": "server/utils/functionsWrapper.js", "max_issues_repo_name": "vincent76110/Gladys", "max_issues_repo_issues_event_min_datetime": "2019-01-13T19:36:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T23:20:47.000Z", "max_forks_repo_path": "server/utils/functionsWrapper.js", "max_forks_repo_name": "vincent76110/Gladys", "max_forks_repo_forks_event_min_datetime": "2015-03-15T11:43:45.000Z", "max_forks_repo_forks_event_max_datetime": "2018-12-30T11:17:44.000Z"}
{"max_stars_count": 1117, "max_issues_count": 1059, "max_forks_count": 233, "avg_line_length": 22.375, "max_line_length": 84, "alphanum_fraction": 0.6424581006}
const logger = require('./logger');

/**
 * @description Wrap a function used to receive an event in a try catch with logging
 * @param {Function} func - The function to wrap.
 * @returns {Function} Return wrap function.
 * @example
 * eventFunctionWrapper(this.add);
 */
function eventFunctionWrapper(func) {
  return async (...args) => {
    try {
      await func(...args);
    } catch (error) {
      logger.warn(`Error while executing ${func}`);
      logger.warn(error);
    }
  };
}

module.exports = {
  eventFunctionWrapper,
};
