超出本地存储限制时,amplify.store是否返回错误或捕获异常? [英] Does amplify.store return error or catch exception when local storage limit exceeded?

查看:130
本文介绍了超出本地存储限制时,amplify.store是否返回错误或捕获异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法检查像这样的调用后是否超出了本地存储限制:

Is there e way to check if local storage limit is exceeded after a call like this:

amplify.store("key", object);

如果我尝试存储大于本地存储限制的东西会发生什么?

What happens if i try to store something bigger than the local storage limit ?

推荐答案

是的,如您在此处看到的那样,它会抛出"amplify.store配额已超出"

yes , it throws "amplify.store quota exceeded" , as you can see here

store.error = function() {
    return "amplify.store quota exceeded"; 
};

...

try {
                    storage.setItem( key, parsed );
                // quota exceeded
                } catch( error ) {
                    // expire old data and try again
                    store[ storageType ]();
                    try {
                        storage.setItem( key, parsed );
                    } catch( error ) {
                        throw store.error();
                    }
                }

这篇关于超出本地存储限制时,amplify.store是否返回错误或捕获异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆