有什麼方法可以避免控制檯上的permission_denied異常轉儲。我不想在控制檯上看到這個異常,並想優雅地處理它。我試過follownig,但它似乎並沒有工作。我也嘗試過.onAuth(),但這也不能阻止這種情況的發生。如何處理Firebase權限正常拒絕異常
var ref = new Firebase(<My firebase root url>),
ref.on("value", function(snapshot) {
console.log("No errors.");
}, function(err) {
console.log("Something is wrong. "+err);
});
Something is wrong. Error: permission_denied: Client doesn't have permission to access the desired data.
SearchCtrl.js:22 User Not Authenticated..Redirecting to Sign In Page...
ionic.bundle.js:19532 Error: permission_denied: Client doesn't have permission to access the desired data.
at Error (native)
at J (http://localhost:8100/lib/firebase/firebase.js:120:48)
at Object.J (http://localhost:8100/lib/firebase/firebase.js:200:378)
at http://localhost:8100/lib/firebase/firebase.js:185:3
at vh.h.Hd (http://localhost:8100/lib/firebase/firebase.js:189:104)
at jh.Hd (http://localhost:8100/lib/firebase/firebase.js:180:364)
at bh.jh.Da.uh.t [as tg] (http://localhost:8100/lib/firebase/firebase.js:178:281)
at eh (http://localhost:8100/lib/firebase/firebase.js:172:464)
at WebSocket.bh.open.va.onmessage (http://localhost:8100/lib/firebase/firebase.js:171:245)(anonymous function) @ ionic.bundle.js:19532c.$$error @ angularfire.min.js:12(anonymous function) @ angularfire.min.js:12(anonymous function) @ angularfire.min.js:12forEach @ ionic.bundle.js:8248g @ angularfire.min.js:12(anonymous function) @ ionic.bundle.js:24148completeOutstandingRequest @ ionic.bundle.js:12830(anonymous function) @ ionic.bundle.js:
ionic.bundle.js:19532 destroy called for FirebaseArray: https://fixmycars.firebaseio.com/customers
ionic.bundle.js:19532 TypeError: Cannot read property '$$error' of null
at angularfire.min.js:12
at angularfire.min.js:12
at Object.forEach (ionic.bundle.js:8248)
at g (angularfire.min.js:12)
at ionic.bundle.js:24148
at completeOutstandingRequest (ionic.bundle.js:12830)
at ionic.bundle.js:(anonymous function) @ ionic.bundle.js:19532$get @ ionic.bundle.js:16482(anonymous function) @ ionic.bundle.js:24151completeOutstandingRequest @ ionic.bundle.js:12830(anonymous function) @ ionic.bundle.js:
這裏的正確答案通常是在訪問數據之前確保用戶具有正確的權限。在大多數情況下,如果客戶端嘗試訪問數據而沒有權限,則可以將其視爲錯誤。由於您將錯誤記錄到控制檯,因此刪除錯誤消息的日誌似乎非常簡單。此外,[指南](https://www.firebase.com/docs/web/guide/)的良好通讀將會爲您節省,堆棧溢出會導致很多抖動。 – Kato
這個異常不是因爲我試圖顯示的錯誤對象。我甚至嘗試刪除該對象,我仍然可以看到該異常。在該行執行後,只需在firebase.js和ionic-bundle.js中來回切換,最後從ionic-bundle.js中返回異常的「self.defer」方法。 – ATHER
看起來像您有一個[XY問題](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem/66378#66378)。 – Kato