Handling Firebase Insufficient Permissions Errors in Flutter

北城以北 提交于 2020-08-07 05:24:07

问题


How can I handle insufficient permissions errors from firebase? I currently do this:

      try {
        DocumentSnapshot doc = await Firestore.instance.collection('SomeCollection').document('SomeDocument').get();
        // Do something
      } catch (error) {
        print('Error: $error');
        // Do something to show user
      }

How ever I can't check for only Permission Errors. Sho how can I catch only insufficient permission errors?

Also when should I use .catchError(), I tried this:

        DocumentSnapshot doc = await Firestore.instance.collection('Some Collection').document('Some Document').get().catchError((onError) {
          // What to do here
        });

I doens't seem to really catch a error, because the exception is still thrown


回答1:


This is supposed to work

 DocumentSnapshot doc = await Firestore.instance.collection('Some Collection').document('Some Document').get().catch((err)=>print(err));


来源:https://stackoverflow.com/questions/55086984/handling-firebase-insufficient-permissions-errors-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!