title: How to return error from firebase function?
body: <p>I have this function:</p>
  
  <pre><code>export const createUser = (email, password) =&gt; 
  firebase.auth().createUserWithEmailAndPassword(email, password)
  .then(res =&gt; console.log(res))
  .catch(error =&gt; {
      console.log(error)
      return error
  });
  </code></pre>
  
  <p>I import this function into my React component, and if it throws an error set the message as it's state:</p>
  
  <pre><code>const process = createUser(email, password)
  console.log(process)
  </code></pre>
  
  <p>But the above logs the functions full details. I tried to catch on the frontend, to get the <code>process.error</code> while put the error into bracket in the exported function, and also tried to get the message somehow like this: <code>process.A.i.L.message</code>, but nothing's worked. How to solve this problem?</p>