summaryrefslogtreecommitdiff
path: root/ext/bg/js/yomichan.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r--ext/bg/js/yomichan.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 61b25816..04f29f42 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -235,15 +235,15 @@ class Yomichan {
}
api_getOptions({callback}) {
- loadOptions().then(opts => callback(opts));
+ loadOptions().then(opts => callback(opts)).catch(() => callback(null));
}
api_findKanji({text, callback}) {
- this.translator.findKanji(text).then(result => callback(result));
+ this.translator.findKanji(text).then(result => callback(result)).catch(() => callback(null));
}
api_findTerm({text, callback}) {
- this.translator.findTerm(text).then(result => callback(result));
+ this.translator.findTerm(text).then(result => callback(result)).catch(() => callback(null));
}
api_renderText({template, data, callback}) {
@@ -252,7 +252,7 @@ class Yomichan {
api_addDefinition({definition, mode, callback}) {
const note = this.formatNote(definition, mode);
- this.anki.addNote(note).then(callback);
+ this.anki.addNote(note).then(callback).catch(() => callback(null));
}
api_canAddDefinitions({definitions, modes, callback}) {
@@ -277,19 +277,21 @@ class Yomichan {
}
callback(states);
+ }).catch(() => {
+ callback(null);
});
}
api_getDeckNames({callback}) {
- this.anki.getDeckNames().then(callback);
+ this.anki.getDeckNames().then(callback).catch(() => callback(null));
}
api_getModelNames({callback}) {
- this.anki.getModelNames().then(callback);
+ this.anki.getModelNames().then(callback).catch(() => callback(null));
}
api_getModelFieldNames({modelName, callback}) {
- this.anki.getModelFieldNames(modelName).then(callback);
+ this.anki.getModelFieldNames(modelName).then(callback).catch(() => callback(null));
}
}