Last active
July 1, 2019 01:50
-
-
Save kunigami/e2415299660eb58ba134a8db78692cd6 to your computer and use it in GitHub Desktop.
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 f() { | |
return Math.random() > 0.5 ? | |
Promise.resolve(10) : | |
Promise.reject(new Error('code x')); | |
} | |
function g() { | |
return f().then(r => { | |
return r + 1; | |
}).catch(e => { | |
return new Error('error:' + e.message); | |
}); | |
} | |
g() | |
.then(r => console.log(r)) | |
.catch(e => console.error(e)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment