Last active
June 26, 2018 05:39
Star
You must be signed in to star a gist
module to handle async/await error handling in a golang kinda way
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
// this file exists just to name the gist, and because gist ordering is asciibetical, it's name starts with a capital letter. |
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
/** | |
* goifyPromise | |
* given a promise, return an array that has the data, and also possibly the error | |
* @param {Promise} | |
* @returns {Array} | |
*/ | |
module.exports = promise => { | |
return promise | |
.then(data => { | |
return [null, data]; | |
}) | |
.catch(err => { | |
return [err]; | |
}); | |
}; |
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
{ | |
"name": "goify-promise", | |
"version": "0.1.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment