Last active
April 11, 2021 08:30
-
-
Save tcomaj/644ba4515d3fea192498e8536ef0723b to your computer and use it in GitHub Desktop.
HOF to handle error in promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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