question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catching Errors/Error Handling - createUserWithEmailAndPassword method

See original GitHub issue

Thanks @tstirrat for sharing the auth.createUserWithEmailAndPassword method on this issue (https://github.com/firebase/emberfire/issues/390). It works great, and by default, errors show up in the console. But the problem is, my custom error callbacks aren’t always firing. It only fires if both the email and password field are set.

Example of the default console log: Error: createUserWithEmailAndPassword failed: First argument “email” must be a valid string. I would like to do a callback on this, so that I can have an error message that says “Email Field Isn’t Set”.

I’ve tried two different approaches, but neither seems to work.

auth.createUserWithEmailAndPassword(email, pass).then(function(userResponse) {
  // Create Record in Store
}).catch(function(error) {
  console.log('test');
}); 

and

auth.createUserWithEmailAndPassword(email, pass).then(function(userResponse) {
  // Create Record in Store
}, function(error){
  console.log('test');
});

Is this a bug? If so, does it have anything to do with the recent angularFire update? https://github.com/firebase/angularfire/releases/tag/v2.0.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tstirratcommented, Jan 5, 2017

See the docs here for createUserWithEmailAndPassword.

The method should return a promise. You should be seeing the code enter the .catch() block when there is an error. If not, make sure you are up to date with the firebase SDK in your package.json.

The error is suggesting that you are passing something other than a string to the action. Very likely you are passing the value undefined. Use console.log or a debug breakpoint to verify the value for email inside the createUser action.

How are you calling the action createUser from your template? You need to pass two parameters to the action in the template, perhaps these are undefined.

1reaction
jpguzmancommented, Jul 29, 2016

I fixed the problem by giving both the email and password default empty values of ‘’, which inherently sets them as strings. Now the catch() fires.

Read more comments on GitHub >

github_iconTop Results From Across the Web

createUserWithEmailAndPasswo...
Error . Methode description : (method) firebase.auth.Auth.createUserWithEmailAndPassword(email: string, password: string): firebase.Promise.
Read more >
Catching Errors/Error Handling - GitHub
It only fires if both the email and password field are set. Example of the default console log: Error: createUserWithEmailAndPassword failed: ...
Read more >
Firebase Auth Tutorial #23 - Catching Auth Errors - YouTube
Hey gang, in this tutorial I'll show you how to catch and display errors.VUE & FIREBASE FULL COURSE ...
Read more >
Error Handling | Firebase Documentation - Google
The Firebase Authentication SDKs provide a simple way for catching the various errors which may occur which using authentication methods.
Read more >
How to use createUserWithEmailAndPassword function in Auth
createUserWithEmailAndPassword (email, password) .catch((error) => { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found