Last active
January 14, 2018 08:40
-
-
Save schahriar/94573c2a088edbb77f6f7809b87f7b29 to your computer and use it in GitHub Desktop.
Try/Catch block complex #async-await #medium
This file contains hidden or 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
| const throwsLater = async () => { | |
| await PromiseThatThrows('Some error'); | |
| }; | |
| async () => { | |
| try { | |
| // Note that without await | |
| // the error will never be | |
| // caught | |
| await throwsLater; | |
| } catch (error) { | |
| console.log(error.message); | |
| // Output: Some error | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment