vhlongon
3/18/2018 - 8:23 PM

hocErrorHandling

HOC wrapping function to decorate async functions that returns a promise if you want all of them to handle error the same way.

const errorHandlingStrategy = e => {
  // do something with the error
  console.log(e);
};
cosnt handleError = fn => (...params) => fn(...params).catch(errorHandlingStrategy);