title: Firebase 3.2.0 - Internal Error on Create User
body: <p>I've just kicked off a new project (Swift 2.2; iOS 9; Xcode 7.3.1) using Firebase 3.2.0 and have hit the following error as part of my authorise/signup process when entering both an invalid email and a weak password:</p>
  
  <p><code>NSError</code></p>
  
  <pre><code>Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and 
  inspect the error details for more information." UserInfo={error_name=ERROR_INTERNAL_ERROR, 
  NSUnderlyingError=0x7c0549a0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" 
  UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey=&lt;CFBasicHash 0x7c04bd90 [0x1a701f8]&gt;
  {type = immutable dict, count = 3,
  entries =&gt;
  0 : &lt;CFString 0x7c0fb0c0 [0x1a701f8]&gt;{contents = "errors"} = 
  &lt;CFArray 0x7c0713a0 [0x1a701f8]&gt;{type = immutable, count = 1, values = (
  0 : &lt;CFBasicHash 0x7c0fac00 [0x1a701f8]&gt;{type = immutable dict, count = 3,
  entries =&gt;
  0 : &lt;CFString 0x7c051080 [0x1a701f8]&gt;{contents = "reason"} = 
  &lt;CFString 0x7c0553f0 [0x1a701f8]&gt;{contents = "invalid"}
  1 : &lt;CFString 0x7c055f30 [0x1a701f8]&gt;{contents = "message"} = 
  &lt;CFString 0x7c061580 [0x1a701f8]&gt;{contents = "INVALID_EMAIL"}
  2 : &lt;CFString 0x7c054fd0 [0x1a701f8]&gt;{contents = "domain"} = 
  &lt;CFString 0x7c060290 [0x1a701f8]&gt;{contents = "global"}
  }
  
  )}
  1 : &lt;CFString 0x7c05aae0 [0x1a701f8]&gt;{contents = "code"} = 
  &lt;CFNumber 0x7c073010 [0x1a701f8]&gt;{value = +400, type = kCFNumberSInt64Type}
  2 : &lt;CFString 0x7c067e70 [0x1a701f8]&gt;{contents = "message"} = 
  &lt;CFString 0x7c0543a0 [0x1a701f8]&gt;{contents = "INVALID_EMAIL"}
  }
  }}, NSLocalizedDescription=An internal error has occurred, print and inspect the error 
  details for more information.}
  </code></pre>
  
  <p>...and my code is as follows....</p>
  
  <p><code>AuthViewController.swift</code></p>
  
  <pre><code>if let email = emailField.text where email != "", let password = passwordField.text where 
    password != "" {FIRAuth.auth()?.signInWithEmail(email, password: password) { (user, error) in
      if let error = error {
              if let errorCode = FIRAuthErrorCode(rawValue: error.code) {
                  switch errorCode {
                  case .ErrorCodeNetworkError:
                      print("A network error occurred")
                  case .ErrorCodeUserNotFound:
                      print("ATTEMPTING TO CREATE USER")
                      FIRAuth.auth()?.createUserWithEmail(email, password: password) { (user, error) in
                          if let error = error {
                              if let errCode = FIRAuthErrorCode(rawValue: error.code) {
                                  switch errCode {
                                  case .ErrorCodeInvalidEmail:
                                      print("invalid email")
                                  case .ErrorCodeWeakPassword:
                                      self.insertErrorLabel("Password is considered weak (&lt; 6 characters). Try again")
                                  default:
                                      print("Create User Error: \(error)")
                                  }
                              }
                          } else {
                              // create a user in the database...
                          }
                      }
                  case .ErrorCodeUserTokenExpired:
  
                  ....
  </code></pre>
  
  <p>Execution hits the .ErrorCodeUserNotFound case in signInWithEmail(). It then hits the default case in createUserWithEmail().</p>
  
  <p>From the docs it appears as though there's an INVALID_EMAIL error key available in the createUserWithEmail() function, however, it appears to be throwing an internal error rather than hitting the InvalidEmail error case.</p>
  
  <p>Three questions:</p>
  
  <ol>
  <li>Do I have an acceptable flow here with signIn failure leading to createUser?</li>
  <li>What's the actual cause of the error?</li>
  <li>How can I address it?</li>
  </ol>
  
  <p>Thanks in advance.</p>