error handling for dictionary fetching errors

This commit is contained in:
adueck 2024-02-11 15:58:02 -05:00
parent 62ba67d677
commit bad6ab1acc
1 changed files with 17 additions and 12 deletions

View File

@ -46,6 +46,7 @@ async function fetchDictionaryInfo(): Promise<T.DictionaryInfo> {
}
export async function updateDictionary(): Promise<"no update" | "updated"> {
try {
const info = await fetchDictionaryInfo();
if (info.release === version) {
return "no update";
@ -60,6 +61,10 @@ export async function updateDictionary(): Promise<"no update" | "updated"> {
lokidb.removeCollection(allWordsCollectionName);
allWordsCollection?.insert(allWords.words);
return "updated";
} catch (e) {
console.error(e);
return "no update";
}
}
function getOneByTs(ts: number): T.DictionaryEntry {