Val*_*nal 5 error-handling dart firebase flutter firebase-storage
我正在为应用程序使用 Flutter 和 Firebase Storage。我试图创建一个函数来知道文件是否存在:
Future<bool> exists(String path) async {
bool _exists;
StorageReference storageReference = FirebaseStorage.instance.ref().child(path);
try {
await storageReference.getDownloadURL();
_exists = true;
} catch (exception) {
_exists = false;
}
return _exists;
}
Run Code Online (Sandbox Code Playgroud)
它正在工作,但是当文件不存在时,它仍然记录错误:
I/System.out(12012): (HTTPLog)-Static: isSBSettingEnabled false
E/StorageException(12012): StorageException has occurred.
E/StorageException(12012): Object does not exist at location.
E/StorageException(12012): Code: -13010 HttpResult: 404
E/StorageException(12012): { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(12012): java.io.IOException: { "error": { "code": 404, "message": "Not Found. Could not get object", "status": "GET_OBJECT" }}
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.parseResponse(com.google.firebase:firebase-storage@@17.0.0:455)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.parseErrorResponse(com.google.firebase:firebase-storage@@17.0.0:435)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.processResponseStream(com.google.firebase:firebase-storage@@17.0.0:426)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:280)
E/StorageException(12012): at com.google.firebase.storage.network.NetworkRequest.performRequest(com.google.firebase:firebase-storage@@17.0.0:294)
E/StorageException(12012): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:70)
E/StorageException(12012): at com.google.firebase.storage.internal.ExponentialBackoffSender.sendWithExponentialBackoff(com.google.firebase:firebase-storage@@17.0.0:62)
E/StorageException(12012): at com.google.firebase.storage.GetDownloadUrlTask.run(com.google.firebase:firebase-storage@@17.0.0:74)
E/StorageException(12012): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/StorageException(12012): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/StorageException(12012): at java.lang.Thread.run(Thread.java:764)
Run Code Online (Sandbox Code Playgroud)
因此,控制台现在充满了这些行,并且很难调试其他任何东西......
我怎样才能隐藏这些线?
谢谢 !
小智 1
捕获这样的错误并处理它
}, onError: (e) {
debugPrint('Exception::: ==========>>>>>>> ${e.toString()}');
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
229 次 |
最近记录: |