What about error handling?
Excellent question!
If you want to use Promise as your container, as we've done in the examples, you can forward the exceptions from the fetchers in a local catch block:
Promise
catch
const rethrow = message => err => { throw new Error(`${message} ${error}`) } const fetchGuests = () => fetch('/friends') .catch(rethrow('Could not fetch guests');
etc. season to taste, then handle them in the top level flow's catch block.
If you want to go buck wild though, you could toss in a few natural transformations. That however, will have to wait for another post :D
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What about error handling?
Excellent question!
If you want to use
Promise
as your container, as we've done in the examples, you can forward the exceptions from the fetchers in a localcatch
block:etc. season to taste, then handle them in the top level flow's catch block.
If you want to go buck wild though, you could toss in a few natural transformations. That however, will have to wait for another post :D