Example #1
0
        public static Firebase.FirebaseException GetFirebaseExceptionFromException(Exception ex)
        {
            Firebase.FirebaseException ret = null;

            if (ex != null)
            {
                ret = ex as Firebase.FirebaseException;

                if (ret == null)
                {
                    AggregateException ag_ex = ex as AggregateException;

                    if (ag_ex != null)
                    {
                        List <Exception> exceptions = ag_ex.InnerExceptions.ToList();

                        for (int i = 0; i < exceptions.Count; ++i)
                        {
                            ret = exceptions[i].InnerException as Firebase.FirebaseException;

                            if (ret != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            return(ret);
        }
Example #2
0
        // Log the result of the specified task, returning true if the task
        // completed successfully, false otherwise.
        protected bool LogTaskCompletion(Task task, string operation)
        {
            bool complete = false;

            if (task.IsCanceled)
            {
                DebugLog(operation + " canceled.");
            }
            else if (task.IsFaulted)
            {
                DebugLog(operation + " encounted an error.");
                foreach (Exception exception in task.Exception.Flatten().InnerExceptions)
                {
                    string errorCode = "";
                    Firebase.FirebaseException firebaseEx = exception as Firebase.FirebaseException;
                    if (firebaseEx != null)
                    {
                        errorCode = String.Format("Error.{0}: ",
                                                  ((Firebase.Messaging.Error)firebaseEx.ErrorCode).ToString());
                    }
                    DebugLog(errorCode + exception.ToString());
                }
            }
            else if (task.IsCompleted)
            {
                DebugLog(operation + " completed");
                complete = true;
            }
            return(complete);
        }
Example #3
0
        public static FastErrorType GetError(Firebase.FirebaseException exception)
        {
            FastErrorType ret = FastErrorType.UNDEFINED;

            if (exception != null)
            {
                Firebase.Auth.AuthError error_code = (Firebase.Auth.AuthError)exception.ErrorCode;

                switch (error_code)
                {
                case Firebase.Auth.AuthError.EmailAlreadyInUse:
                {
                    ret = FastErrorType.EMAIL_ALREADY_IN_USE;
                    break;
                }

                case Firebase.Auth.AuthError.AccountExistsWithDifferentCredentials:
                {
                    ret = FastErrorType.ACCOUNT_ALREADY_EXISTS;
                    break;
                }

                case Firebase.Auth.AuthError.InvalidEmail:
                {
                    ret = FastErrorType.INVALID_EMAIL;
                    break;
                }

                case Firebase.Auth.AuthError.UserNotFound:
                case Firebase.Auth.AuthError.WrongPassword:
                {
                    ret = FastErrorType.WRONG_CREDENTIALS;
                    break;
                }

                case Firebase.Auth.AuthError.InvalidCredential:
                {
                    ret = FastErrorType.INVALID_CREDENTIAL;
                    break;
                }

                case Firebase.Auth.AuthError.WeakPassword:
                {
                    ret = FastErrorType.WEAK_PASSWORD;
                    break;
                }

                case Firebase.Auth.AuthError.NetworkRequestFailed:
                case Firebase.Auth.AuthError.WebInternalError:
                case Firebase.Auth.AuthError.Failure:
                {
                    ret = FastErrorType.NETWORK_ERROR;
                    break;
                }

                default:
                {
                    ret = ret = FastErrorType.UNDEFINED;
                    break;
                }
                }
            }

            return(ret);
        }