Guest User

Untitled

a guest
Feb 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const apiCall = async () => {
  2. throw new Error('Big Bug')
  3. }
  4.  
  5. async function autofulfill() {
  6. console.log('Autofulfill...');
  7. try {
  8. return await apiCall() // we need to `await` here, otherwise the error will be caught at this level!
  9. } catch (err) {
  10. console.log('> autofulfill catch bug!')
  11. }
  12. }
  13.  
  14. async function start() {
  15. try {
  16. console.log('Start');
  17. await autofulfill()
  18. console.log('The end');
  19. }
  20. catch (err) {
  21. console.log('Main catch, TOO BAD!')
  22. }
  23. }
  24.  
  25. start()
Add Comment
Please, Sign In to add comment