title: In Swift-iOS How I catch User Authentication erros in AWS Cognito?
body: <p>I'm trying aws cognito user pool and got stacked in the user sign up process. I already configured my user pool and are executing the sign-up method, but I can find a way to get the error code returned by aws services. Here my user pool instantiation, that is working fine:</p>
  
  <pre><code>let poolConfig = AWSCognitoIdentityUserPoolConfiguration(
                   clientId: userPool_clientId,
                   clientSecret: userPool_secret,
                   poolId: userPool_id)
  
  AWSCognitoIdentityUserPool.registerCognitoIdentityUserPool(with: poolConfig,
                                                            forKey: userPoll_App)
  
  userPool = AWSCognitoIdentityUserPool(forKey: userPoll_App)
  </code></pre>
  
  <p>Then, in my view controller I have a Button whit a @IBAction with this:</p>
  
  <pre><code>    if userPool != nil {
  
          let attName = AWSCognitoIdentityUserAttributeType()!
          attName.name = "name"
          attName.value = userNome
  
          let attLast = AWSCognitoIdentityUserAttributeType()!
          attLast.name = "family name"
          attLast.value = userSobrenome
  
          let attEmail = AWSCognitoIdentityUserAttributeType()!
          attEmail.name = "email"
          attEmail.value = userEmail
  
          var result:Bool = false
          userPool!.signUp(userNome,
                           password: userPwd,
                           userAttributes: [attName, attLast, attEmail],
                           validationData: nil).continue({(task:AWSTask!) in
  
                              if (task.error != nil) {
                                  print (task.error!)
                                  result = false
                              } else {
                                  result = true
                              }
  
                              return nil
  
                          })
  </code></pre>
  
  <p>After that code, I test the result to see if it is true or false and take the appropriate action. But...</p>
  
  <p>I'm having different errors in this process and I need to evaluate this errors in development time. For example, the first error that I got was because I misconfigured the AWS region. Ok! Game on!! But the second error was because the password informed by the user did not passed the validation of the pool. In this case, I want to know the error was because the validation process and inform the user to take the appropriate action. I do not want to have this logic in the iOS app. The task.error object just give a localized description property and it is not very helpful.</p>
  
  <p>By the way: I'm using Swift 3.2, iOS 10.2, aws-ios-sdk2 and Xcode 8.</p>