diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-10-17 20:02:50 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-10-17 20:02:50 -0700 |
commit | 6cd1f70baad516e3844e0e79dbac4147443747ce (patch) | |
tree | 17b9e163e682f0a759cb242159bec70bf24755e2 /ext/bg/js | |
parent | 0afc4579c550ab32921a0f1a5bbd2568451edff5 (diff) |
Error handling
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/yomichan.js | 16 |
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)); } } |