问题
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