如何从Unity的实时数据库中获取数据库错误?

时间:2019-07-10 01:14:25

标签: c# ios firebase unity3d firebase-realtime-database

设置

团结:2019.1.6f1 Firebase版本:6.2.0 Firebase产品:实时数据库

我的使用情况

  internal static DatabaseReference Content()
  {
     return DBReference.Child("content");
  }

添加数据

     CloudSession.Content().Child(_childNode).SetRawJsonValueAsync(_jsonValue).ContinueWith(
        (_task) =>
        {
            if (_task.IsCanceled == true)
            {
                Debug.Log("DB UPLOAD Cancelled -> ");

                if (_task.Exception is System.AggregateException _aggregateException)
                {
                    if (_aggregateException.InnerExceptions[0] is DatabaseException _innerException)
                    {
                        //_innerException.
                    }
                }
            }

            if (_task.IsFaulted == true)
            {
                Debug.Log("DB UPLOAD faulted -> ");
            }

            switch (_task.IsCompleted)
            {
                case true:
                    Debug.Log("New value updated!!! -> " + _childNode);
                    break;
            }
            Debug.Log("--------- DB COMPLETED ---------");
        });

查看数据

      CloudSession.Content().Child(_childNode).GetValueAsync().ContinueWith(
        (_task) =>
        {
            if (_task.IsCanceled == true)
            {
                Debug.Log("DB RETRIVE Cancelled -> " + _task.Exception);
            }

            if (_task.IsFaulted == true)
            {
                Debug.Log("DB RETRIVE faulted -> " + _task.Exception);
            }

            switch (_task.IsCompleted)
            {
                case true:
                    Debug.Log("JSON value obtained!!!");
                    DataSnapshot _snapshot = _task.Result;

            }
        });

删除数据

  CloudSession.Content().Child(_childNode).RemoveValueAsync().ContinueWith(
       (_task) =>
       {
           if (_task.IsCanceled == true)
           {
               Debug.Log("DB NODE DELETE Cancelled -> " + _task.Exception);
           }

           if (_task.IsFaulted == true)
           {
               Debug.Log("DB NODE DELETE faulted -> " + _task.Exception);
           }

           switch (_task.IsCompleted)
           {
               case true:
                   Debug.Log("NODE DELETE COMPLETE-> " + _childNode + " -> "+ _task.Status);
                   break;
           }
       });

请求

  • 当IsCanceled或IsFaulted出现故障时,如何获取数据库错误代码。我无法从github示例仓库或文档中找到任何相关示例。[ \Firebase Database Error Documentation]
  • 是否有任何有关何时以及如何收到此类错误的信息。这背后的原因是因为在执行数据库操作时禁用设备上的Internet时,我从未出现任何“网络”错误。

谢谢

0 个答案:

没有答案