From 7449ffd4dc74ea79c1e7337a6402b1c697c0a875 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 5 Apr 2020 18:26:38 -0400 Subject: Fix error reporting during dictionary import --- ext/bg/js/dictionary-importer.js | 2 +- ext/bg/js/settings/dictionaries.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/bg/js/dictionary-importer.js b/ext/bg/js/dictionary-importer.js index 589e7656..607a8b5e 100644 --- a/ext/bg/js/dictionary-importer.js +++ b/ext/bg/js/dictionary-importer.js @@ -180,7 +180,7 @@ class DictionaryImporter { try { await database.bulkAdd(objectStoreName, entries, i, count); } catch (e) { - errors.push(e); + errors.push(errorToJson(e)); } loadedCount += count; diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 5e59cc3d..ed883869 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -643,9 +643,9 @@ async function onDictionaryImport(e) { await settingsSaveOptions(); if (errors.length > 0) { - errors.push(...errors); - errors.push(`Dictionary may not have been imported properly: ${errors.length} error${errors.length === 1 ? '' : 's'} reported.`); - dictionaryErrorsShow(errors); + const errors2 = errors.map((error) => jsonToError(error)); + errors2.push(`Dictionary may not have been imported properly: ${errors2.length} error${errors2.length === 1 ? '' : 's'} reported.`); + dictionaryErrorsShow(errors2); } onDatabaseUpdated(); -- cgit v1.2.3 From 9dfe531dfd75af0eec26d532a40095fe8a982df1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 5 Apr 2020 18:27:53 -0400 Subject: Use logError instead of console.log --- ext/bg/js/database.js | 2 +- ext/bg/js/settings/dictionaries.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 7a4d094b..4a677fea 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -99,7 +99,7 @@ class Database { }); return true; } catch (e) { - console.error(e); + logError(e); return false; } } diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index ed883869..00056e2e 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -505,7 +505,7 @@ function dictionaryErrorsShow(errors) { if (errors !== null && errors.length > 0) { const uniqueErrors = new Map(); for (let e of errors) { - console.error(e); + logError(e); e = dictionaryErrorToString(e); let count = uniqueErrors.get(e); if (typeof count === 'undefined') { -- cgit v1.2.3