删除存储数据时,如果数据使用deleteObject(Storageref)时是否存在错误?
我正在创建删除用户数据功能。此功能的一部分是清洁存储。 如果用户一开始没有映像,则会生成错误,以停止其余功能的例外,如何防止此错误形式发生,而无需检查并提出get请求以查看是否有数据在存储中开始?
错误信息 : 对象“配置文件/ID”不存在。 (存储/对象 - 未找到)
// Delete user's Storage Data
const storage = getStorage();
const storageRef = ref(storage, `profiles/${currentUser.uid}`);
await deleteObject(storageRef);
// Delete the user
await deleteUser(currentUser);
I am creating a delete user data function. One part of this function is to clean storage.
If the user don't have an image to begin with, an error is generated halting the exception of the rest of the function, how to prevent this error form happening, without having to check and make a get request to see if there is data in storage to begin with ?
Error message :Object 'profiles/id' does not exist. (storage/object-not-found)
// Delete user's Storage Data
const storage = getStorage();
const storageRef = ref(storage, `profiles/${currentUser.uid}`);
await deleteObject(storageRef);
// Delete the user
await deleteUser(currentUser);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如@johnhanley所述,您可以使用异常处理并捕获错误。
请参阅下面有关如何实现异常处理的示例代码:
您可以参考此对于其他可用错误消息。
As mentioned by @JohnHanley, you can use exception handling and catch the error.
See sample code below on how to implement exception handling:
You can refer to this documentation for other available error messages.