error handling for dictionary fetching errors
This commit is contained in:
parent
62ba67d677
commit
bad6ab1acc
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue