alexlafroscia / use-task

A React hook for running and cancelling asynchronous tasks
https://use-task.now.sh
24 stars 1 forks source link

How to handle a yielded error or rejection #10

Open alexlafroscia opened 5 years ago

alexlafroscia commented 5 years ago

I can imagine a few ways that yielding an error (or Promise rejection) should be handled

  1. Treat it like any other value
    • Task is still "successful"
    • .error is not set
  2. Treat is like a thrown error
    • Task enters the "error" state
    • .error is set to the thing that was Promise's rejection value

I'm not sure which makes more sense -- currently 1 is how it is handled, but I would like to get input ton other perspectives on how it should be handled.