facebookexperimental/Recoil

Allow greater control in errorSelector

Open

#637 aperta il 7 ott 2020

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (1151 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (19.428 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

errorSelector currently takes a custom message as a parameter and passes that message into a newly constructed Error object.

Current: errorSelector("This is my error message")

I believe that asking for an Error object as the argument instead of a message would allow for greater control and flexibility.

Proposed: errorSelector(new Error("This is my error message")) Proposed:

errorSelector(() => { 
  let e = new Error(); 
  e.name = "AuthError"; 
  e.message = "User is not logged in"; 
  return e; 
})

If this is functionality that we would like to see in Recoil, I would love to submit a PR on this.

Guida contributor