Skip to content

Instantly share code, notes, and snippets.

@tcomaj
Last active April 11, 2021 08:30
Show Gist options
  • Save tcomaj/644ba4515d3fea192498e8536ef0723b to your computer and use it in GitHub Desktop.
Save tcomaj/644ba4515d3fea192498e8536ef0723b to your computer and use it in GitHub Desktop.
HOF to handle error in promise
// Function to handle error
function handleError(fn) {
return function(...params) {
return fn(...params).catch(function (err) {
// do something with the error
console.error(`Oops!`, err);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment