facebookexperimental/Recoil

Allow greater control in errorSelector

Open

#637 opened on Oct 7, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (19,428 stars) (1,151 forks)batch import
enhancementhelp wanted

Description

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.

Contributor guide