Does amplify.store return error or catch exception when local storage limit exceeded?

和自甴很熟 提交于 2019-12-04 03:24:58

问题


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 ?


回答1:


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();
                    }
                }


来源:https://stackoverflow.com/questions/12508274/does-amplify-store-return-error-or-catch-exception-when-local-storage-limit-exce

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!