Add error handling to accessing disk cache Fixes #3747

2af33a9e1879d470764e03e5bc1e5a4a22e5f3ea

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +8 -0Showing whitespace changes
src/endpoints/characters.js+8 -0
@@ -171,16 +171,24 @@ async function readCharacterData(inputFile, inputFormat = 'png') {
171171 return memoryCache.get(cacheKey);
172172 }
173173 if (useDiskCache) {
174+ try {
174175 const cachedData = await diskCache.instance().then(i => i.getItem(cacheKey));
175176 if (cachedData) {
176177 return cachedData;
177178 }
179+ } catch (error) {
180+ console.warn('Error while reading from disk cache:', error);
181+ }
178182 }
179183
180184 const result = await parse(inputFile, inputFormat);
181185 !isAndroid && memoryCache.set(cacheKey, result);
182186 if (useDiskCache) {
187+ try {
183188 await diskCache.instance().then(i => i.setItem(cacheKey, result));
189+ } catch (error) {
190+ console.warn('Error while writing to disk cache:', error);
191+ }
184192 }
185193 return result;
186194}