Error Handling swift

Hi @joao.marques.
In Swift you can cast the error object to something more specific, like an AuthenticationError:

Auth0
    .webAuth()
    .start {
        switch $0 {
        case .failure(let error as AuthenticationError):
            print("Error code: \(error.code), description:\(error.description), info:\(error.info), statusCode:\(error.statusCode)")
        case .failure(let error):
            print("Error: \(error.localizedDescription)")
        case .success(let credentials):
            _ = self.credentialManager.store(credentials: credentials)
            print("Login success")
        }
}
3 Likes